Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Oct 2002
    Location
    Buffalo, NY
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    IFRAME onreadystatechange

    Occasionally I Need Help, And I Cant Find It Anywhere Else...

    So Anyhow, I have an IFRAME in an HTML page.

    <iframe id="filegetter" name="filegetter" src=""></iframe>

    and i have A bit of mr Javascript As Well

    <script>
    fgdoc=document.getElementById("filegetter");
    function cin(){
    url="file_to_get.txt";
    filegetter.location.replace(url);
    fgdoc.onreadystatechange=function chkld(){
    if(fgdoc.readyState=="complete"){
    alert(filegetter.document.body.innerText);
    setTimeout('cin()',2000);
    }
    }
    }


    cin();

    </script>

    Yes.. Theres A Function Inside A Function.
    Works Great In IE (As Usual );

    What It Should Do...
    the javascript function cin() is called;
    the IFRAMEs location is changed (it Will be Different);
    the IFRAME's status is checked and if it returns "complete"
    Alert the Contents of the file (just for testing);

    In all actuality, all i need to do is check if the IFRAME's current page location is fully loaded and if so, get the contents of the IFRAME's document.body

    Am I Going About This The Hard Way ?
    Is There A Cross-Browser Compatible Way To Do It ?

    As Usual,
    Thanx 2-N-E-N All That Reply

  • #2
    Regular Coder
    Join Date
    Aug 2005
    Posts
    282
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    <iframe onload="checkMe(event,this.contentWindow)"></iframe>
    
    // script
    function checkMe(e, win) {
      alert(win.location.href);
    }

  • #3
    New Coder
    Join Date
    Oct 2002
    Location
    Buffalo, NY
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Alrighty, Now Heres The Thing.

    I Had Something Similar to that.

    Turns Out that because I Was Just Using The Alert Function Soley For testing
    , The Inner HTML Of The Iframes Current Page Was Blank, And A Blank Alert ie. alert('');
    will not even show in netscape,
    There NEEDS To be Content Inside..

    i Dont Remember If This Was Ever An Issue Before With Netscrap;
    But I'm Using The Newest Version - V8.0

    STATUS : RESOLVED

    THX


  •  

    Posting Permissions

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