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

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

Logo

Dynamic Headline Fader, Version 2.01
Hierarchical Menu Script compatibility


Both Scripts Together

WebReference

New



Changes

In order to get the two scripts working together, we have made these changes to the HTML and JavaScript files:

Note: These changes are for using the Hierarchical Menu and Fader Scripts in the same page only. They do not reflect permanent changes to either of the scripts. You must be familiar with both scripts to appreciate the changes.

The Page HTML

The parameter variables and the external file loading for the two scripts are combined:

<SCRIPT LANGUAGE="JavaScript">
<!--
    NS4 = (document.layers);
     IE4 = (document.all);
   isMac = (navigator.appVersion.indexOf("Mac") != -1);
  IE4mac = (IE4 && isMac);
  isMenu = (NS4 || (IE4 && !isMac));
function popUp(){return};
function popDown(){return};
function startIt(){return}
if (!ver4) event=null;
FDRboxWid = 150;
FDRboxHgt = 80;
FDRbackCol = "white";
FDRborWid = 5;
FDRborCol = "maroon";
FDRborSty = "solid";
FDRboxPad = 12;
FDRblendInt = 3;
FDRblendDur = 1;
FDRmaxLoops = 2;
FDRlnkDec = "none";
FDRtxtAln = "center";
FDRfntCol = "black";
FDRlnkCol = "maroon";
FDRhovCol = "red";
FDRfntSiz = "10pt";
FDRfntWgh = "bold";
FDRfntSty = "normal";
FDRfntFam = "Geneva,Arial,sans-serif";
FDRlinHgt = "11pt";
FDRendWithFirst = false;
FDRreplayOnClick = true;
FDRgifInt = 60;
FDRgifSrc = "fade.gif";
if (isMenu) {
   menuVersion = 3;
   menuWidth = 120;
   childOverlap = 50;
   childOffset = 5;
   perCentOver = null;
   secondsVisible = .5;
   fntCol = "blue";
   fntSiz = "10";
   fntBold = false;
   fntItal = false;
   fntFam = "sans-serif";
   backCol = "#DDDDDD";
   overCol = "#FFCCCC";
   overFnt = "purple";
   borWid = 2;
   borCol = "black";
   borSty = "solid";
   itemPad = 3;
   imgSrc = "tri.gif";
   imgSiz = 10;
   imgHspace = 0
   separator = 1;
   separatorCol = "red";
   isFrames = false;
   keepHilite = true; 
   NSfontOver = true;
   clickStart = false;
   clickKill = true;
}
//-->
</SCRIPT>
<SCRIPT LANGUAGE="JavaScript1.2">
<!--
if (isMenu) {
document.write('<SCRIPT LANGUAGE="JavaScript1.2" SRC="hierArrays.js"><\/SCRIPT>');
document.write('<SCRIPT LANGUAGE="JavaScript1.2" SRC="hierMenusBOTH.js"><\/SCRIPT>');
}
document.write('<SCRIPT LANGUAGE="JavaScript1.2" SRC="news.js"><\/SCRIPT>');
document.write('<SCRIPT LANGUAGE="JavaScript1.2" SRC="faderBOTH.js"><\/SCRIPT>');
//-->
</SCRIPT>

The Fader Script

We have called this special version of the script faderBOTH.js and made two changes:

  1. The onload handler:

    window.onload = FDRcountLoads;

    is now activated conditionally, only if the HM script is not loaded. That is, if the browser does not support menus (isMenu is false):

    if (!isMenu) window.onload = FDRcountLoads;
  2. The same condition is applied to the resize handler:

    if (!isMenu) {
       origWidth = innerWidth;
       origHeight = innerHeight;
       window.onresize = function(){
          if (innerWidth==origWidth && innerHeight==origHeight) return;
          location.reload();
       }
    }

The Hierarchical Menu Script

This version of the HM script is called hierMenusBOTH.js and has one change. It calls the fader load handler function, when the menus have been built, at the end of its startIt() function:

function startIt() {
   .
   .
   .
   FDRcountLoads();
}

Download

These scripts, together with a sample page, are available for download in ZIP format.

Now that we've helped make the fader script compatible with other scripts, let's make it compatible with an older version of itself.


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/fdr201both.html