Web host music - 223Chapter 16 .Window and Frame Objects Navigator 2

223Chapter 16 .Window and Frame Objects Navigator 2 Bug: Parent Variables Some bugs in Navigator 2 cause problems when accessing variables in a parent window from one of its children. If a document in one of the child frames unloads, a parent variable value that depends on that frame may get scrambled or disappear. Using a temporary doc- ument.cookie for global variable values may be a better solution. For Navigator 3, you should declare parent variables that are updated from child frames as first-class string objects (with the new String() constructor) as described in Chapter 34. Frame synchronization A pesky problem for some scripters plans is that including immediate scripts in the framesetting document is dangerous if not crash-prone in Navigator 2. Such scripts tend to rely on the presence of documents in the frames being created by this framesetting document. But if the frames have not yet been created and their documents have not yet loaded, the immediate scripts will likely crash and burn. One way to guard against this problem is to trigger all such scripts from the frameset s onLoad event handler. In theory, this handler won t trigger until all documents have successfully loaded into the child frames defined by the frameset. Unfortunately, IE4+ for Windows has a nasty bug that fires the onLoad event handler in the frameset even if the loading has been interrupted by the browser s Stop button or pressing the Esc key. At the same time, be careful with onLoad event handlers in the documents going into a frameset s frames. If one of those scripts relies on the presence of a document in another frame (one of its brothers or sisters), you re doomed to eventual failure. Anything coming from a slow network or server to a slow modem can get in the way of other documents loading into frames in the ideal order. One way to work around these problems is to create a Boolean variable in the parent document to act as a flag for the successful loading of subsidiary frames. When a document loads into a frame, its onLoad event handler can set that flag to true to indicate that the document has loaded. Any script that relies on a page being loaded should use an if construction to test the value of that flag before proceeding. Despite the horrible IE4+/Windows bug described above, it is best to construct the code so that the parent s onLoad event handler triggers all the scripts that you want to run after loading. Depending on other frames is a tricky business, but the farther the installed base of Web browsers gets from Navigator 2, the less the associated risk. For example, beginning with Navigator 3, if a user resizes a window, the document does not reload itself, as it used to in Navigator 2. Even so, you still should test your pages thoroughly for any residual effects that may accrue if someone resizes a window or clicks Reload. Blank frames Often, you may find it desirable to create a frame in a frameset but not put any document in it until the user has interacted with various controls or other user interface elements in other frames. Navigator and recent IE versions have a somewhat empty document in one of its internal URLs (about:blank). But with
In case you need affordable webhost to host your website, our recommendation is ecommerce web host services.

Leave a Reply