Click to See Complete Forum and Search --> : document acess denied error
mwong7025
June 2nd, 2005, 12:47 PM
Is there a way to check if a document is finished loading? I have a Javascript that does Iframe, and will use that to open a new window periodically. However if I call it with short interval, a lot of times it would fail with access denied because of the page is still loading. The script failed with the following code:
} else if (IFrameObj.document) {
// For IE5
IFrameDoc = IFrameObj.document; // failed here!!!
Dr. Script
June 2nd, 2005, 03:26 PM
You could palce the code in the onload event handler:<script type="text/javascript">
// ...
onload = function() {
// ---;
// ---;
// ---;
}
// ...
</script>That's your *best* option I suppose, while there are others.
mwong7025
June 6th, 2005, 02:41 PM
Can i use Try... Catch block to catch the document access error? If so, what type of error to catch, exception?
Dr. Script
June 6th, 2005, 02:52 PM
I suggest using the try .. catch block. It is a good idea. You'd plcae the intended code in the try portion, and just an error message in the catch. You could force the error by deleting the text boxes to see exactly what the error is if you'd like to only alert for that specific error.
mwong7025
June 10th, 2005, 12:04 PM
Thanks for your reponse.
I am able to catch the exception, but the problem is the script is dead after the exception occured. Does the script stop after exception and is there any way to keep it alive? The function suppose to be called periodically as follows:
setInterval("callToServer()",10000);
function callToServer()
{
try {
if (IFrameObj.document)
// For IE5
IFrameDoc = IFrameObj.document;
} catch(exception) {
alert("exception")
return false;
}
}
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.