| the complete webmaster | ||||
| tutorials | reviews | reference | ||
|
home / articles / javascript JavaScript + Dynamic HTML + MSIE4 = Cool web pagesWeb pages are traditionally very limited in the way information can be presented. While the current HTML specification is sufficient for presenting static information, it is often nice to be able to create dynamic web pages that look more like interactive CD-ROMs. Thankfully, Microsoft's Dynamic HTML (DHTML) addresses some of the shortcomings of HTML. With IE4, it is possible to treat every element on a page as an object that can be moved, resized and changed at will. This makes for some interesting possibilities that are only now beginning to be explored. Unfortunately, the version of DHTML supported in Netscape 4 is much more limited than that supported by Internet Explorer 4, so the example on this page will not work with Netscape or in any other web browsers. But the script is well worth trying out - after all, if your competitors have IE4 enhanced sites, your web site visitors may not be too impressed with your static looking pages. If you have ever been to Microsoft's sitebuilder network then you will most likely find their DHTML documentation quite mysterious. However, help is at hand. The example on this page will show you how straightforward it is to combine JavaScript and DHTML to change the look of the web page in response to user interaction. The example uses a combination of JavaScript and DHTML to provide a small multimedia demonstration. Click on the buttons to see an appropriate image and a brief description of each fruit:
How it works:
The top part of this script is some fairly standard code for making sure that the script is only executed by Internet Explorer 4. The rest of the script contains the various functions that are carried out in response to clicking on the buttons. For example, when the button labelled Banana is clicked on, it executes the banana_text function of this script. This function does two things: it changes the fruit_description text span to display some text about the banana, thereby replacing the existing text. It also changes the image source of the image with the ID of fruit_picture. This script can be easily modified to suit a variety of other situations. Let me know if you find an interesting use for it. Don't forget that the script only works at present with Internet Explorer 4. If you want your web site visitors to be able to check if they have the right web browser (you will be surprised at the number of people who browse the web without knowing the version of their browser) then you could use a variation of the following script: browseversion= parseInt(navigator.appVersion); Of course, if you are designing an Intranet site that will only be viewed by people using IE4, then you won't need to worry so much. Modern web servers such as Microsoft's Internet Information Server also allow you to easily serve up different pages according to the capabilities of the client browser. So you could easily build a home page enhanced for IE4, and a standard page for all other browsers. Author: Brett Burridge More articles about JavaScript |
| write for us | about us | advertise |
Copyright 1997, 1998 A Big Lime. All rights reserved.