Add a JavaScript menu to your web site

From The IT Community
Jump to: navigation, search




This will show you how to add a JavaScript menu to your web site.

In this example we use it to access some pages on The IT Community in a fast and simple way.


First put the following into the <head> section of your site:

<SCRIPT LANGUAGE="JavaScript">
 <!--
 function openDir (form) {
        if (form.directory.selectedIndex == 0)
                parent.window.location.href="http://www.theitcommunity.com/wiki/Special:NewestPages"
        if (form.directory.selectedIndex == 1)
                parent.window.location.href="http://www.theitcommunity.com/wiki/Special:PopularPages"
        if (form.directory.selectedIndex == 2)
                parent.window.location.href="http://www.theitcommunity.com/wiki/Create_a_new_Page"
        if (form.directory.selectedIndex == 3)
                parent.window.location.href="http://www.theitcommunity.com/wiki/Help:Contents"
 }
 // end of script -->
 </SCRIPT>

This is your JavaScript menu which defines where the links point to.

Now put the following into the <body> section of your site:

<FORM NAME="myform">
 <SELECT NAME="directory">
    <OPTION SELECTED="SELECTED">Newest Pages</OPTION>
    <OPTION>Popular Pages</OPTION>
    <OPTION>Create a new Page</OPTION>
    <OPTION>Help</OPTION>
 </SELECT>
 <INPUT TYPE="button" NAME="button" VALUE=" Go " ONCLICK="openDir(this.form)">
</FORM>


That´s it, refresh your page and have fun with your new menu.



Was this article helpful? Then please donate to keep The IT Community alive...

If you found this article helpful please share it, comment and help others by writing your own article.






Translate this page:




Articles found in the same category:
(max. 20 shown)