1

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.

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.

1
  • You want to click somewhere and replace your iframe with other content without refresh? Commented Mar 4, 2015 at 0:34

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.