Valhalla Legends Forums Archive | Web Development | Modifying iframes with Javascript

AuthorMessageTime
iago
I tried to do something like this:

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

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

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?
October 17, 2004, 2:41 PM
zorm
try
[code]onclick="parent.test.location.href='http://www.valhallalegends.com/';"[/code]
October 17, 2004, 4:29 PM
iago
Aha, this worked beautifully:

[code]<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>
[/code]

Thanks, zorm!
October 17, 2004, 6:11 PM

Search