DHTML Menus
"Dynamic HTML, a standard extending HTML, consisting of HTML 4.0, CSS, DOM and scripting languages."
The power of DHTML means that HTML can be modified at will, with no cost to the server, as all the content is loaded into the browser. CSS style elements can control the look and feel of the HTML elements and combine the HTML and CSS with Javascript then DHTML is born!
The commonest DHTML uses javascript events, which call on CSS or HTML functions. For example: the simplest DHTML function is a hide or display function:
Simple Hide / Show DHTML
function Hide(HTMLElement){ document.getElementById('HTMLElement').style.display = 'none'; }
function Show(HTMLElement){ document.getElementById('HTMLElement').style.display = ''; }
The hide and show principle is exactly what we are using for the above tab menu.
Click 'Simple' on the menu for the next section.
Menus from Lists
Dynamic menus can be made from a number of resources, images, tables or lists.
Lists are perhaps the most powerful as CSS can style the lists with more control than
tables.
So take a simple List:
A Simple List:
<div class="MenuListDiv">
<ul class="menuList" id="menu">
<li class="menuBranch">
<span class="menuBranchSpan">
<a href="" id="menuBranch0" class="branch"> Top Menu </a>
</span>
<ul id="branchItems0" class="menu">
<li class="menuItem">
<span class="menuItemSpan">
<a href="#"> Link </a>
</span>
</li>
<li class="menuBranch">
<span class="menuBranchSpan">
<a href="" id="menuBranch1" class="actuator"> Sub Menu </a>
</span>
<ul id="branchItems1" class="menu">
<li class="menuItem">
<span class="menuItemSpan">
<a href="#"> Link 1 </a>
</span>
</li>
<li class="menuItem">
<span class="menuItemSpan">
<a href="#"> Link 2 </a>
</span>
</li>
</ul>
</li>
<li class="menuItem">
<span class="menuItemSpan">
<a href="#"> Link 3 </a>
</span>
</li>
</ul>
</li>
<li class="menuBranch">
<span class="menuBranchSpan">
<a href="" id="menuBranch2" class="actuator"> Another Menu </a>
</span>
<ul id="branchItems2" class="menu">
<li class="menuItem">
<span class="menuItemSpan">
<a href="#"> link </a>
</span>
</li>
</ul>
</li>
</ul>
</div>
Without Any HTML Classes it would look like this: Now lets go on to look at how CSS and DHTML can be used to make the menus dynamic.
Perhaps the future of these menus is through XUL. I only heard about XUL very recently and the technology is exciting. Having briefly investigated the language its great potential is obvious. However, its not quite there yet and standards need to be implemented so that it is supported across browsers.
The following link is an example of the previous menus in XUL.
This example is Firefox and Mozilla compatable only.
XUL Example Menu