|
I am hiding/displaying an image on one frame from another frame.
For that I am using the following code on the frame to hide image of another frame. :
parent.fraHeader.frmNavigator.imgPrint.style.visibility='visible';
This is working fine. However, sometimes it gives an error that parent.fraHeader.frmNavigator.imgPrint is Null or Not an Object.
This error is completely random in nature and occurs at very rare instances. I havent been able to find any reason for it or simulate it.
Both the frames are called together from one page and I have a feeling that this error may be coming because the frame that holds the image hasnt downloaded the image as yet, and the second frame already tries to call it to set its visibility.
Can this be the case? Please help me.
|
|
|
It is definitely a possibility that the error occurs because script in one frame is attempting to access elements in another frame that don't exist yet...and you'd only see it in the rare occasion the script fires before the image exists.
You can handle this by putting an onload even in the frame where the image lives. That frame can do something like this in your javascript:
var pageLoaded = false;
function LoadTrigger() {
pageLoaded = true;
}
window.onload = LoadTrigger;
|
|
Then in your other frame, your script to hide/show the image could first check to see if the page is loaded with code similar to this:
if (parent.fraHeader.frmNavigator.pageLoaded) {
parent.fraHeader.frmNavigator.imgPrint.style.visibility='visible';
}
|
|
Of course, you may have other issues, and there are other ways to handle this, but this is one method I've used successfully.
|
|
|
|
|
|
|
|
|
|