Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

replace the source of an IFRAME

Status
Not open for further replies.

TyzA

Programmer
Joined
Jan 7, 2002
Messages
86
Location
BE
Hi,

Is it possible to change the src for an IFRAME with javascript?

I'm trying stuff like:
// javascript
function redirect(){
document.testingframe.src="http;//}
// html
<form onsubmit=&quot;redirect()&quot;>
<input type=&quot;submit&quot; value=&quot;accessiores&quot;>
</form>
<iframe id=&quot;testingframe&quot; name=&quot;dataFrame&quot; src=&quot;cgi-bin/test2.cgi&quot; frameborder=&quot;0&quot; height=&quot;400&quot; hspace=&quot;5&quot; width=&quot;650&quot;></iframe>

Thanks for any help.
Tijs
 
you should use getElementById() to be cross-browser compatible, and &quot;http;&quot; should be &quot;http:&quot;:
Code:
function redirect(){
    document.getElementById(&quot;testingframe&quot;).src = &quot;[URL unfurl="true"]http://www.mail.be&quot;;[/URL]
}

=========================================================
-jeff
try { succeed(); } catch(E) { tryAgain(); }
 
Thanks guys
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top