Opening/Changing a Iframe using a click event in wordpress

On my WordPress website, I have a menu down one side and a embedded prezzie within an IFrame next to the menu.

I want to use some form of click event to change the content of the IFrame to another prezie without the page being refreshed, to give it a seamless change but I am stuck on how to write the code.

Read More

The menu buttons are actually pictures trapped in a map, to give the illusion they are actually functional buttons.

Can anyone help me with this please?

Thanks in advance.

Related posts

Leave a Reply

1 comment

  1. Add a JavaScript function to swap the Url of the Prezi iframe.

    function changePrezi (preziKey) {
      var url = "http://prezi.com/embed/" + preziKey + "/";      
      document.getElementById('prezi').src = url;
    }
    

    Then add onClick handlers to your menu links/buttons to call the changePrezi function, passing in the proper Prezi key.

    <button onClick="changePrezi('ltv92t40up8k')">Prezi 1</button>
    <button onClick="changePrezi('rqqnh_taqx1l')">Prezi 2</button>
    <iframe id="prezi" frameborder="0" width="550" height="400"></iframe>
    

    Here is a Plunker Demo.