...

View Full Version : change source of iframe after page has loaded



dja770
02-03-2011, 04:05 PM
Im very new to java scripting so any help would be truly appreciated. I have a single web page that loads several iframes. One of the iframe pages has to be logged in first. I have that taken care of but once the page is loaded I need to change the source to a link with in the page. My guess is I need something to execute the code like a onload or something. This is what Ive been trying to get to work but like I said a newb!

The iframe in question is named "cad"
the initial source once loaded is 'https://urlname.com/mainmenu.asp'
the source I need to change to is 'https://urlname.com/UnitStatusF.asp?agency_id=28'

[CODE]
function ChangesSrc()
{
var iframeid = document.getElementById(cad);
var unitstatus = 'https://urlname.com/UnitStatusF.asp?agency_id=28'
if (iframeid.src = 'https://urlname.com/mainmenu.asp')
iframeid.src = unitstaus;
return false;
}
[[CODE]

Philip M
02-03-2011, 04:43 PM
Like this:-


<html>
<head>
<script type = "text/javascript">
function changesrc() {
if (document.getElementById("myframe").src = "http://www.yahoo.com") {
document.getElementById("myframe").src = "http://www.google.com";
}
}
</script>
</head>

<body onload = "changesrc()">

<iframe height = "500" width = "800" id="myframe" src = "http://www.yahoo.com">

</div>
</body>
</html>

Your closing CODE tag is wrongly shown as [[CODE]

"I know that you believe that you understand what you think I said, but, I am not sure you realise that what you heard is not what I meant". (Robert
McCloskey)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum