|

|
|
|
Many web sites now use a system of pop-out menus in their navigation systems.
The pop-out menus provide several links, and display when the user mouses
over a navigation category. A simple example of this can be seen on this
page:
pop-out example
Usually, pop-out menus are created with layers, using JavaScript to
show and hide the layers. The trick is managing how the pop-out layers
show and hide at the appropriate times. For example, you want the pop-out
to disappear if the user doesn't make any selection. These are the actions
that have to be accommodated in pop-out menues:
- show the pop-out layer on mouseOver of nav link
- hide the pop-out layer if the user moves to another nav link
- keep the pop-out layer visible on mouseOver of the sub-nav links
in the pop-out
- hide the pop-out layer after a delay on mouseOut of the pop-out -
the delay is important so if the user accidentally mouses off, the
menu doesn't disappear immediately.
|
|
|
|
- Turn off Dreamweaver's Visual Aids so the yellow icons do not interfere
with positioning of graphics and layers.
- Set the document to have no margins (in MODIFY>PAGE PROPERTIES)
so the layers will line up properly with images in the background.
- Create and place graphics for each navigation link. Make these graphics
into links using the "#" so you can add behaviors later.
- Create a layer for each nav link's pop-out, positioning it in the
location where it should appear.
- Name each layer
- Place sub-nav links (graphics or plain text) into the new pop-out
layers.
|
|
|
The below timer code is used to create an action that hides any
visible pop-out after the user mouses away from the navigation system.
A delay
(1 second or whatever you set it to)
before hiding is used to keep the pop-out visible if the user temporarily
mouses out.
- The timer action is initiated whenever the user leaves (onMouseOut)
any of the navigation links. This hides the pop-out layers if the user
stays out of the links for more than 1 second.
- The timer action must be cancelled when the user enters (onMouseOver)
any navigation link. This prevents the timer from hiding a pop-out
that should be active.
- Create a dummy link with a behavior to create some
JavaScript we will use later.
- Insert some text on the page away from the menu system, and
make it a link with "#"
- Add an action to that link using the Show-Hide Layers behavior
- The behavior should hide all the pop-out layers
- Insert the following code into the head section of the document,
inside the existing JavaScript code area already created by Dreamweaver.
Put the code after this existing code in the
page:
<script language="JavaScript">
<!--
// start of custom pop-out code
// philip van allen vanallen@artcenter.edu
//
var timerID = "global";
function hideMenus()
{
// insert the MM_showHideLayers function you create that
// hides all popout layers. Be sure you put a semi-colon
// at the end of the code. Here is an example:
// MM_showHideLayers('products','','hide','sales','','hide');
}
function startTimer()
{
stopTimer();
// the number "700" is the number of milli-seconds (thousands-of-a-second)
timerID = setTimeout("hideMenus()", 700);
}
function stopTimer()
{
clearTimeout(timerID);
}
// end of custom code
|
|
- Locate the dummy link you created earlier and select it
- View the HTML and copy the MM_showHideLayers code from the link.
For example:
MM_showHideLayers('products','','hide','sales','','hide')
- Paste this code into the custom JavaScript section in function hideMenus() --
see above code -- be sure to add a semicolon on the end ";"
|
|
- For each of the MAIN nav links, add the following behaviors:
- onMouseOver: Show/Hide Layers: show the pop-out layer
for this nav, hide all other pop-out layers.
-- Display the pop-out for this nav link, and hide any other pop-outs
currently visible.
- onMouseOver: Call JavaScript: stopTimer()
-- Cancel any active timers to prevent them from hiding the current
pop-out.
- onMouseOut: Call JavaScript: startTimer()
-- Start the timer so all pop-outs are hiden after 1 second.

- For each of the SUB-nav links, add the following behaviors:
- onMouseOver: Call JavaScript: stopTimer()
-- Cancel any active timers to prevent them from hiding the current
pop-out.
- onMouseOut: Call JavaScript: startTimer()
-- Start the timer so all pop-outs are hiden after 1 second.
|
|
All of the pop-out layers should be hidden so they are not visible when
the page loads:
- Select the layer
- In the Layers palette, hide the layer by selecting the closed eye
icon.
|
|
|
Find the dummy link you created earlier, and remove it completely.
|
|
|
Preview the page to verify that the pop-out menus are working correctly.
|
|