DHTML Lab - dhtmlab.com - Dynamic Headline Fader, Version 2.01 | 12 | WebReference

DHTML Lab - dhtmlab.com - Dynamic Headline Fader, Version 2.01 | 12

Logo

Dynamic Headline Fader, Version 2.01
accounting for the this problem in NS4mac


The Problem

Brian McNett alerted us to the following problem:
In Netscape 4.04, on the Mac, double-clicking on the fader to restart is broken. Netscape returns the following error:

This problem exists on other NS releases, like 4.05, as well. More recent versions have fixed the bug.

Judging from the error message, one assumes the problem is with the releaseEvents() method. It isn't.

In some releases of NS4mac, there is a bug with the assignment of the this keyword.

The statement that generates the error is in our FDRend() function:

function FDRend(){
   .
   .
   .
   if (FDRreplayOnClick) {
      .
      .
      .
      if (IE4) {
         .
         .
         .
      }
      else {
         elFader.captureEvents(Event.DBLCLICK);
         elFader.ondblclick = function(){

            this.releaseEvents(Event.DBLCLICK);
            FDRstart(startIndex);
            return false;
         }
      }
   }
}

The syntax is correct, and this should refer to the elFader object. In some versions of NS4mac, this is not assigned to the correct object, and, in our script, whatever object this is assigned to, does not have a releaseEvents() method, so the error is generated.

The Solution

We'll avoid the this bug completely, by referring to the elFader object directly:

function FDRend(){
   .
   .
   .
   if (FDRreplayOnClick) {
      .
      .
      .
      if (IE4) {
         .
         .
         .
      }
      else {
         elFader.captureEvents(Event.DBLCLICK);
         elFader.ondblclick = function(){

            elFader.releaseEvents(Event.DBLCLICK);
            FDRstart(startIndex);
            return false;
         }
      }
   }
}

We're finished, but for some final comments.


Produced by Peter Belesis and

All Rights Reserved. Legal Notices.
Created: Sep 21, 1999
Revised: Sep 21, 1999

URL: http://www.webreference.com/dhtml/column25/addendum1/fdr201nsmac.html