Reputation: 1
I've been researching for the last hour trying to find out how to change the whole iframe with javascript. All of these websites are telling me (frame.src = URL); though all of that stuff isn't working. Every time I keep trying reload codes after it such as:
frame.contentDocument.location.reload(true);
Nothing is working though, can anybody help me! Just give me a single code to change the whole page of the iframe? Maybe a JSFiddle page too to help me understand, thanks! I would really appreciate it!
Upvotes: 0
Views: 47
Reputation: 10305
Lets say you have an iFrame set-up as follows :
<iframe id="thisFrame" src="http://www.w3schools.com/"></iframe>
You can use Javascript to change the src
like so:
document.getElementById('thisFrame').src= "http://www.w3schools.com/tags/tag_iframe.asp";
As simple as that.
Here's a fiddle for demonstration : http://jsfiddle.net/YWce5/1/
Upvotes: 0
Reputation: 118
Following code works on pretty much all the web browsers, you should try testing you own code and the following code in different browsers to make sure where the fault is
var iframe = document.getElementById('youriframe');
iframe.src = iframe.src;
Upvotes: 1