codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  displaying/hiding image of one frame from another frame  ishanbansal at 14:35 on Friday, February 06, 2004
 

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.

  Re: displaying/hiding image of one frame from another frame  Troy Wolf at 03:59 on Tuesday, February 24, 2004
 

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.
Troy Wolf: site expert
Shiny Solutions









CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  Testing file for type of data
•  Running VB6 application as a ASP.NET application
•  login system with asp.net
•  Re: Help: Trouble with z-Index and SELECT lists
•  What is wrong with this ASP codes? It don`t seem to work???
•  Need help with ListBox control
•  Re: Good Javascript/DHTML Reference
•  Re: scrolling table
•  Re: simulation of road traffic


Recent Articles
Communicating with the Database (Using ADO)
MagicGrid
Simple Thumbnail Browsing Solution
Type Anywhere
A Better Moustrap: FmtDate to replace FormatDateTime
ASP.NET Forum Source Code
Internal Search Engine
Javascript Growing Window
Simple date validation
Search engine friendly URLs using ASP.NET (C#.NET)


Site Survey
Help us serve you better. Take a five minute survey. Click here!

© Copyright codetoad.com 2001-2004