Valhalla Legends Archive

Programming => Web Development => Topic started by: iago on October 17, 2004, 09:41 AM

Title: Modifying iframes with Javascript
Post by: iago on October 17, 2004, 09:41 AM
I tried to do something like this:

<iframe src="http://www.google.ca" name="test"></iframe>

<input type="button" value="click me" onclick="
test.src='http://www.valhallalegends.com'">


When I click the button, the javascript console says:
Error: uncaught exception: Permission denied to set property Window.src

Is there any way to set the src attribute of an iframe?
Title: Re: Modifying iframes with Javascript
Post by: Zorm on October 17, 2004, 11:29 AM
try
onclick="parent.test.location.href='http://www.valhallalegends.com/';"
Title: Re: Modifying iframes with Javascript
Post by: iago on October 17, 2004, 01:11 PM
Aha, this worked beautifully:

<html>

<input type="button" value="test" onclick="parent.test.location.href='http://www.valhallalegends.com/';"><br><br>
                         
This is my test iframe:<br>     
<iframe src="http://www.google.ca" name=test></iframe><br>

</html>


Thanks, zorm!