Example Javascript
Executing Javascript from the Menu Bar.

In this example we demonstrate how the menu bar can be used to execute javascript functions within the current page. Within this page there is a simple piece of javascript which show's or hide's a table depending upon the supplied parameter. Here we have a menu bar with just two buttons one will execute the javascript to make the table visible and the second will execute the javascript to hide the table.

Note: If javascript is to be used then the "mayscript" element in the applet tag must be present and the target element of the item must be set to "javascript".

And here is applet html code,

<applet code="MenubarApplet" archive="AdvMenubar.jar" width="200" height="30" mayscript>
<param NAME="cabbase" VALUE="AdvMenubar.cab">

<param name="backgroundColor" value="0,0,0">

<!-- Menu's -->
<param name="menu1" value="root|100|30|0|255,255,255">

<!-- Item's -->
<!-- Menu Id | Submenu Id | Background color | Arrow color | Divide line | Mouseover bg color | Mouseover text color | Mouseover effect | Mouseclick bg color | Mouseclick text color | Mouseclick effect | Border effect | Normal image | Mouseover image | Mouseclick image | Image position | Item text | Text position | Text color | Text font | Url | Target frame | Sound - Submenu open | Sound - Submenu close | Sound - Button click | Status bar message -->

<param name="item1" value="root| |57,156,255|0,64,128|false|0,97,193|170,213,255|2|0,97,193|170,213,255|0|1|select|select2| |3,3|Show Table|30,20|0,64,128|Helvetica,N,12|combo('show')|javascript">
<param name="item2" value="root| |57,156,255|0,64,128|false|0,97,193|170,213,255|2|0,97,193|170,213,255|0|1|look|look2| |3,3|Hide Table|30,20|0,64,128|Helvetica,N,12|combo('hide')|javascript">

<!-- Images -->
<param name="image1" value="select|./IconImages/select.gif">
<param name="image2" value="select2|./IconImages/select2.gif">
<param name="image3" value="look|./IconImages/look.gif">
<param name="image4" value="look2|./IconImages/look2.gif">

</applet>

And here is the Javascript function,

<SCRIPT LANGUAGE="JavaScript">

var table='hide';
function combo(table) {

if (table=='hide') {document.all.c1.style.visibility="hidden";}
if (table=='show') {document.all.c1.style.visibility="visible";}
}

</SCRIPT>

 

Return to example Index - click here.