...

View Full Version : IFRAME onreadystatechange



GrimChild
09-15-2005, 12:23 AM
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

KC-Luck
09-15-2005, 03:48 PM
<iframe onload="checkMe(event,this.contentWindow)"></iframe>

// script
function checkMe(e, win) {
alert(win.location.href);
}

GrimChild
09-15-2005, 10:23 PM
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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum