Comments
Richard Davies wrote: The UK has a good crop of technology pioneers in cloud computing - for example ElasticHosts, FlexiScale, Flexiant, OnApp - and also some strong government initiatives such as G-Cloud. We will have to see whether this kind of technical leadership converts into swift mass-market adoption or not.
Cloud Expo on Google News


2008 West
DIAMOND SPONSOR:
Data Direct
SOA, WOA and Cloud Computing: The New Frontier for Data Services
PLATINUM SPONSORS:
Red Hat
The Opening of Virtualization
GOLD SPONSORS:
Appsense
User Environment Management – The Third Layer of the Desktop
Cordys
Cloud Computing for Business Agility
EMC
CMIS: A Multi-Vendor Proposal for a Service-Based Content Management Interoperability Standard
Freedom OSS
Practical SOA” Max Yankelevich
Intel
Architecting an Enterprise Service Router (ESR) – A Cost-Effective Way to Scale SOA Across the Enterprise
Sensedia
Return on Assests: Bringing Visibility to your SOA Strategy
Symantec
Managing Hybrid Endpoint Environments
VMWare
Game-Changing Technology for Enterprise Clouds and Applications
Click For 2008 West
Event Webcasts

2008 West
PLATINUM SPONSORS:
Appcelerator
Get ‘Rich’ Quick: Rapid Prototyping for RIA with ZERO Server Code
Keynote Systems
Designing for and Managing Performance in the New Frontier of Rich Internet Applications
GOLD SPONSORS:
ICEsoft
How Can AJAX Improve Homeland Security?
Isomorphic
Beyond Widgets: What a RIA Platform Should Offer
Oracle
REAs: Rich Enterprise Applications
Click For 2008 Event Webcasts
SYS-CON.TV
Top Links You Must Click On


Active Menus Without Graphics
Active Menus Without Graphics

There's a problem faced by all Web designers: making a menu look interesting without taking forever to load.

Many modern applications address this problem using active menus that indicate where the mouse is by changing the color of the menu items as the mouse cursor passes over them. (Pull down any standard menu on a Windows machine to see this in action.) On Web pages this is often done by a JavaScript application that swaps images, but this technique is slow, and it doesn't work in all browsers.

In this article I'll show how to build this kind of active menu with text, not graphics. This "change style on hover" feature is built into Dynamic HTML in Microsoft Internet Explorer, but in Netscape Communicator 4 this trick requires cascading style sheets, layers and JavaScript. This technique saves download time by using text menus instead of images. There's only one connection from the client to the server, and the text is much smaller than an image of text, even with a few hundred bytes of JavaScript. In addition, since the entire menu is in one HTML file, configuration control is easier when you need to update your menu.

The Easy Way
Doing this in Microsoft Internet Explorer 4 is easy, thanks to style sheets. There's a quick example shown in Listing 1.

There are three things to notice here. First, we're using cascading style sheets, as described at www.microsoft.com/msdn/sdk/inetsdk/help/dhtml/dhtml.htm.

Second, the STYLE tags use HTML comments, !-- and --, to hide the style descriptions from older browsers.

Third, the hover pseudoclass is defined with a gray background and italic font. See www.eu.microsoft.com/msdn/sdk/inetsdk/help/dhtml/references/css/hover.htm for details.

But this doesn't work in the most popular browser, Netscape 4. To do this, we need to mix several techniques: a little JavaScript, Netscape's inline layers and style sheets.

The Hard Way
Unfortunately, Netscape 4 doesn't allow you to change the style of an element on a page after it's been rendered on the screen, so this hover thing doesn't work. But it does let you change the contents of layers at any time. See http://developer.netscape.com/docs/manuals/communicator/dynhtml/contents....

Each element of the following JavaScript application works in both MSIE 4 and Netscape 4, and is downward-compatible with other browsers, as seen in Listing 2, instead of having a link as in Listing 3.

In MSIE and older versions of Netscape, the onMouseOver event triggers the JavaScript make_bg_gray() function, but because the global var do_the_layers is zero, this will do nothing. (Same with make_bg_null().) MSIE 4 will activate its hover pseudoclass normally, giving us the same effect as in the simple previous example.

But Netscape 4.0 (and any other JavaScript-compatible browser supporting layers) will use the onMouseOver and onMouseOut events to trigger make_bg_gray() and make_bg_null() to change the background color of the inline layer (ILAYER). Slow computers like my old 486 don't always trigger the onMouseOut event, so we always turn the background back again three seconds after entry. Setting the background color to null instead of document.bgColor makes the area transparent, in case you're using a background image on the page. (Because of the way we styled the hover pseudoclass, MSIE 4 will show the text as italic on hover; Netscape 4 will not.)

Unfortunately, a bug in the X Window System/SunOS version of Netscape 4 makes it crash when this code is invoked, so we've put in a little guard code, showing why it's always good practice to test your JavaScript code under all available browsers.

Conclusion
This little program demonstrates some of the advanced features of MSIE 4 and Netscape 4, while retaining backward compatibility with older browsers. If you find a use for these active menus or the techniques you've learned here, drop me a line.

About Ken Jenks
Ken Jenks has been programming for more than 23 years. He holds a BS in computer science, an MS in aerospace engineering and is working on a Ph.D. in mechanical engineering. In his day job he works for the federal government. Evenings and weekends he runs a Web-based publishing company, Mind's Eye Fiction (visit http://tale.com)

In order to post a comment you need to be registered and logged in.

Register | Sign-in

Reader Feedback: Page 1 of 1

Enterprise Open Source Magazine Latest Stories . . .
Apache Deltacloud, the Red Hat-contributed ReSTful API that abstracts differences between clouds so services on any cloud can be managed – provided of course there’s a driver – has graduated from the Apache Foundation’s incubator and is now a full-fledged Top-Level Project (TLP). The...
With Cloud Expo 2012 New York (10th Cloud Expo) just four months away, what better time to start introducing you in greater detail to the distinguished individuals in our incredible Speaker Faculty for the technical and strategy sessions at the conference... We have technical and st...
AMD said late Tuesday that its chief sales officer Emilio Ghilardi had left the company and that CEO and president Rory Read is going to do his job while a replacement is sought. AMD didn’t say why Ghilardi left but it’s assumed Read wants his own people. Read is relatively new to th...
During the lifespan of M3 (Monitis Monitor Manager) there has always been something lacking – timers. M3 execution procedure was outlined in this previous article. The execution mentioned in the latter was a one-time-execution, whereas server monitoring requires periodic invocati...
Red Hat is putting its bought-in Gluster scale-out NAS storage technology, acquired in October, on the Amazon cloud. It’s styled Red Hat Virtual Storage Appliance for Amazon Web Services and other clouds are supposed to follow in short order.
A new episode of the screencast series is now available at the OpenNebula YouTube Channel. This screencast demonstrates the new easily-customizable self-service portal for cloud consumers. Its aim is to offer a simplified access to shared infrastructure for non-IT end users. The scree...
Subscribe to the World's Most Powerful Newsletters
Subscribe to Our Rss Feeds & Get Your SYS-CON News Live!
Click to Add our RSS Feeds to the Service of Your Choice:
Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
Publish Your Article! Please send it to editorial(at)sys-con.com!

Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021


SYS-CON Featured Whitepapers
ADS BY GOOGLE