Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Feb 2011
    Thanked 0 Times in 0 Posts

    change source of iframe after page has loaded

    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'

    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;

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    London, England
    Thanked 2,563 Times in 2,541 Posts
    Like this:-

    <script type = "text/javascript">
    function changesrc() {
    if (document.getElementById("myframe").src = "http://www.yahoo.com") {
    document.getElementById("myframe").src = "http://www.google.com";
    <body onload = "changesrc()">
    <iframe height = "500" width = "800" id="myframe" src = "http://www.yahoo.com">
    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


    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts