spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / dhtml / column15

Logo

Cross-Browser Hierarchical Menus
the main script

Webreference

Contents

You know the routine.

In longer script listings, cross-browser code is blue, Navigator-specific code is red, and Explorer code is green.

Developer News
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?

Our main external script, in its cross-browser version, begins in exactly the same way as the Navigator-specific one. First, a CSS stylesheet, defining a class named .items, is created dynamically, using our several of our parameter variables:

semi = ";";

styleStr = "<STYLE TYPE='text/css'>"
styleStr += ".items {"
styleStr += "width:" + menuWidth + semi
styleStr += "color:"+ fntCol + semi
styleStr += "font-size:"+ fntSiz + semi
styleStr += "font-weight:"+ fntWgh + semi
styleStr += "font-style:"+ fntSty + semi
styleStr += "font-family:"+ fntFam + semi
styleStr += "border-width:" + borWid + semi
styleStr += "border-color:" + borCol + semi
styleStr += "border-style:" + borSty + semi
styleStr += "line-height:" + linHgt + semi
styleStr += "}"
styleStr += "</STYLE>";
 
document.write(styleStr);

The above creates what, if hard-coded, would look like this:

<STYLE TYPE='text/css'>"
<!--
    .items {
        width: 120;
        color: black;
        font-size: 12px;
        font-weight: normal;
        font-style: normal;
        font-family: sans-serif;
        border-width: 2px;
        border-color: #CC0000;
        border-style: outset;
        line-height: normal;
    }
-->
</STYLE>

Our global variables, our triangle image string and our onload event handler are defined.

if (perCentOver != null) {
    childOverlap = (perCentOver/100) * menuWidth
}
mSecsVis = secondsVisible * 1000;
imgStr = "<IMG SRC=" + imgSrc + " WIDTH=" + imgSiz
   + " HEIGHT=" + imgSiz
   + " BORDER=0 VSPACE=2 ALIGN=RIGHT>";
topCount = 1;
areCreated = false;
isOverMenu = false;
currentMenu = null;
allTimer = null;
window.onload = makeTop;

As before, when our page has loaded, control is passed to the makeTop() function.


Produced by Peter Belesis and

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Rolling Out Your Own HTML Application Version Control · HTML 5: Client-side Storage · Working with Ajax Server Extensions
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Wi-Fi Product Watch, November 2009 · Chip Market Recovering From '08 Collapse · Low-Cost Tools to Kickstart Your New Business

All Rights Reserved. Legal Notices.
Created: Feb. 27, 1998
Revised: Feb. 27, 1998

URL: http://www.webreference.com/dhtml/column15/menu2Begin.html