Scrolling HTML Basics, Part I: Netscape Navigator's Problems - Doc JavaScript | WebReference

Scrolling HTML Basics, Part I: Netscape Navigator's Problems - Doc JavaScript


Netscape Navigator's Problems

As previously discussed, we have found a few serious problems with Netscape Navigator's layers implementation. Although we worked around them, we wanted to summarize what we found. Avoiding these problems in your scripts can save you a lot of debugging and frustration.

The first problem is the inability to call a function after we load a layer with an HTML feed. In both makeFirstPage() and makeSecondPage() functions, any continuation of the function must be done through a delayed execution via the onload event handler. Here is the makeFirstLayer() again:

function makeFirstPage() {
  firstPage = new Layer(Gwidth,canvas);
  firstPage.src = Gsrc;
  upperPage = firstPage;
  firstPage.onload = makeSecondPage;
  firstPage.onMouseOver = stopScrolling;
  firstPage.onMouseOut = scrollPages;  
}

Any attempt to call the makeSecondPage() directly and immediately, or any call to any function for that matter, will result in a broken scroller.

The same problem applies in the makeSecondPage() function:

function makeSecondPage() {
  secondPage = new Layer(Gwidth,canvas);
  secondPage.src=Gsrc;
  secondPage.onMouseOver = stopScrolling;
  secondPage.onMouseOut = scrollPages;
  lowerPage = secondPage;
  secondPage.onLoad = launchScroller;
}

Any attempt to call the launchScroller() immediately and directly, or any other function for this matter, will result in a broken scroller.

The third problem is the need to return true from the rotatePages() function:

function rotatePages() {
        if (upperPage == firstPage) {
        upperPage = secondPage;
        lowerPage =firstPage;
        return true;
        }
        upperPage=firstPage;
        lowerPage=secondPage;
        return true;
}

Any attempt to remove the return true; statements will break the scroller after a few cycles.

http://www.internet.com

Produced by Yehuda Shiran and Tomer Shiran

Created: November 23, 1998
Revised: November 23, 1998

URL: http://www.webreference.com/js/column30/problems