I have an iframe
that looks like this:
<iframe src="http://www.google.com" height=1000 width="500" id="myiframe"></iframe>
I want to create a link so that when I click on it, the iframe on the page changes. How can I do that using jQuery? Is it related to jQuery attr
?
When you can communicate with the code inside an iFrame, you can make any change you want to the code within that iFrame.
You can embed an iframe in a page that is inside another iframe on another web page. When you set the target attribute to _parent, the link will open in the web page that is holding the iframe. In most situations with iframes, this target will open links in the same way that the _parent target does.
Set the iframe to the appropriate width and height and set the scrolling attribute to "no". If the area you want is not in the top-left portion of the page, you can scroll the content to the appropriate area.
You don't need jQuery for that. You don't even need JavaScript for that.
Give your iframe a name
, and target your anchors to point to it:
<a href="foo.html" target="myiframe">Foo</a>
<a href="bar.html" target="myiframe">Bar</a>
<a href="baz.html" target="myiframe">Baz</a>
<iframe name="myiframe"></iframe>
This degrades nicely for people who have JavaScript turned off.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With