I have a fairly long script which basically makes a menu. I wanted it like this as it is really easy for me to add more items to it. you can see it at:
http://acid.freewebpage.org
Now, why does it only work on IE?
Here's the code:
Code:<%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%> <html> <head> <title>Acidic Library - Home</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <script src="menu.js"></script> <script language="JavaScript"> if (navigator.appName != "Microsoft Internet Explorer") { alert("sorry, but so far this site is only Internet Explorer compatible. I'm trying to fix this.") } function make_menu() { var gmenu = document.getElementById('linksmenu') gmenu.innerHTML = "<table><tr>" for (i=0; i<main_list.length; i++) { gmenu.innerHTML += "<td><br><br><span id='" + main_list[i][0] + "' onClick='sub_menu(this.id)' STYLE='cursor: pointer'>" + main_list[i][0] + "</span></td>" } gmenu.innerHTML += "</tr></table>" } function sub_menu(id) { for (i=0; i<main_list.length; i++) { if (id == main_list[i][0]) { if (main_list[i][0] != document.getElementById(id).innerHTML) //Submenu is already open { document.getElementById(id).innerHTML = main_list[i][0] } else { if (main_list[i][1] == 0) //If menu item goes to URL, not opens submenu { document.location = main_list[i][2] } else //If menu item opens submenu { var mmenu = document.getElementById(id) mmenu.innerHTML = "<td><i><span id='" + main_list[i][0] + "' onClick='sub_menu(this.id)' STYLE='cursor: pointer'><br>" + main_list[i][0] + "</i></span></b><br><br></td>" for (j=0; j<eval(id).length; j++) { mmenu.innerHTML += "<a href='" + main_list[i][2] + "" + eval(id)[j][1] + "'>" + eval(id)[j][0] + "</a><br>" } } } } } } </script> </head> <body background="background.jpg" bgproperties="fixed" onLoad="make_menu()"> <table width="80%" border="5" align="center" cellpadding="0" cellspacing="20" bordercolor="#7979FF" bgcolor="#E6E6FF"> <tr> <td width="28%"> <p><b><b></b><span id="linksmenu">Generating List...</span></b></p></td> <td width="72%"> <p>Hi and welcome to the most boring part of the site. On the left you have the list of all my script. If you have any construcive comments or want to contribute to this website, please feel free to contact me. <hr> <p><br> <strong>News:<br> </strong>15/11/03<br> Made the pointer cursor show on the menu. Started making VB application that you can download and browse through the scripts. Realised that this will take time.</p> <p>12/11/03<br> Adding JavaScripts to the list, getting very bored of it. Made the JScript.html page. Put page on-line</p> <p><Br> 10/11/03<br> Started making the site.<br> Got the menu sorted, adding things to it.</p> </td> </tr> </table> <p> </p> </body> </html>
here's the menu.js file:
Code://List to go into the menu main_list = new Array() main_list[0] = ["Home","0","index.html"] main_list[1] = ["JavaScript","1","http://acid.freewebpage.org/JScript.html?"] main_list[2] = ["Contact","0","contact.html"] main_list[3] = ["Links","1","http://"] JavaScript = new Array() JavaScript[0] = ["Bubble Sort","0001"] JavaScript[1] = ["Temperature Conversion","0002"] JavaScript[2] = ["Matrix","0003"] JavaScript[3] = ["BBC news","0004"] JavaScript[4] = ["Changing cell data","0005"] JavaScript[5] = ["Opacity","0006"] JavaScript[6] = ["Cookies","0007"] JavaScript[7] = ["Scrolling news","0008"] Links = new Array() Links[0] = ["JS-World","www.js-x.com"] Links[1] = ["HTML Goodies","www.htmlgoodies.com"]
P.S. can I specify the code type for HTML/JavaScript as you can with VB?





Reply With Quote