Hi all i will try to be as clear as possible!
I am currently working on a site for a customer at www.privacymaker.com/gcs/dev/ (where im developing it, the main site location is www.gerbercentral.com)
well here is the issue i am running into.
I have decided to go with mouseovers that change the innerHTML of an element, at first if you tried to mouse over the tags while the page was loading it would cause the page to abort loading and you would get an error message.
I decided that it may be due to me trying to reference an HTML element that had not been drawn yet.
so i inserted the line
document.getElementById && document.getElementById("LEFTNAV"))
{//continue code}
thinking that it would only execute the script if it could find the required element and only if the browser supported it...well i guess i was wrong because i am still getting crashes.
here is a copy of important HTML and the javascript file itself
<div align="justify">
<font class="navigation">
<a href="./networking.php" onMouseOver="displayNav( 'networking', '1' )" onMouseOut="restoreNav()">Networking</a> |
<a href="./hardsoft.php" onMouseOver="displayNav( 'hardwaresoftware', '1')" onMouseOut="restoreNav()">Hardware/Software</a> |
<a href="./viruses.php" onMouseOver="displayNav('virus', '1')" onMouseOut="restoreNav()">Viruses</a> |
<a href="./os.php" onMouseOver="displayNav('os', '1')" onMouseOut="restoreNav()">Operating Systems</a> |
<a href="./helpticket.php" onMouseOver="displayNav('webhelp', '1')" onMouseOut="restoreNav()">Web Based Help Tickets</a> |
<a href="./webdesign.php" onMouseOver="displayNav('webdes', '1')" onMouseOut="restoreNav()">Web Design</a> |
<a href="./training.php" onMouseOver="displayNav('training', '1')" onMouseOut="restoreNav()">Training</a>
</font>
<font id="LOGIN"><font class="login">
<a href="./login.php">Customer Login</a>
</font></font>
</div>
this calls the functions and here are the functions
function displayNav( location, level )
{
var path;
//if the document has not loaded yet do NOT do this procedure
//will cause a browser crash due to elements needed not being renderd yet
if(document.getElementById && document.getElementById("LEFTNAV") && document.getElementById("navhead")){ //is required piece loaded?
stopDelay();
//check to see what level they are on
if(level == 1) {
//top level directory
path = "./";
path += location;
} else {
//level two
path = "../";
path += location;
}
switch(location)
{
case "networking":
document.getElementById("LEFTNAV").innerHTML = "<table align=\"left\" class=\"rpxtable\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td height=\"21px\" onMouseOver=\"this.className='yellowBG'\" onMouseOut=\"this.className='normal'\"><font class=\"navtext\"><a href=\"#\">Wire(less) Networking</a></font></td></tr><tr><td class=\"shader\"></td></tr><tr><td height=\"21px\" onMouseOver=\"this.className='yellowBG'\" onMouseOut=\"this.className='normal'\"><font class=\"navtext\"><a href=\"#\">Microsoft Servers</a></font></td></tr><tr><td class=\"shader\"></td></tr><tr><td height=\"21px\" onMouseOver=\"this.className='yellowBG'\" onMouseOut=\"this.className='normal'\"><font class=\"navtext\"><a href=\"#\">Linux Servers</a></font></td></tr><tr><td class=\"shader\"></td></tr><tr><td height=\"21px\" onMouseOver=\"this.className='yellowBG'\" onMouseOut=\"this.className='normal'\"><font class=\"navtext\"><a href=\"#\">VLAN / VPN</a></font></td></tr><tr><td class=\"shader\"></td></tr><tr><td height=\"21px\" onMouseOver=\"this.className='yellowBG'\" onMouseOut=\"this.className='normal'\"><font class=\"navtext\"><a href=\"#\">Cable Installation</a></font></td></tr><tr><td class=\"shader\"></td></tr><tr><td height=\"21px\" onMouseOver=\"this.className='yellowBG'\" onMouseOut=\"this.className='normal'\"><font class=\"navtext\"><a href=\"#\">Network Hardware Setup</a></font></td></tr><tr><td class=\"shader\"></td></tr><tr><td height=\"21px\" onMouseOver=\"this.className='yellowBG'\" onMouseOut=\"this.className='normal'\"><font class=\"navtext\"><a href=\"#\">Remote Support</a></font></td></tr><tr><td class=\"shader\"></td></tr></table>"
document.getElementById("navhead").innerHTML = "<font class=\"header\">Networking</font>"
break
case "hardwaresoftware":
document.getElementById("LEFTNAV").innerHTML = "<table align=\"left\" class=\"rpxtable\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td height=\"21px\" onMouseOver=\"this.className='yellowBG'\" onMouseOut=\"this.className='normal'\" ><font class=\"navtext\"><a href=\"#\">Install/Removal</a></font></td></tr><tr><td class=\"shader\"></td></tr><tr><td height=\"21px\" onMouseOver=\"this.className='yellowBG'\" onMouseOut=\"this.className='normal'\"><font class=\"navtext\"><a href=\"#\">Upgrades</a></font></td></tr><tr><td class=\"shader\"></td></tr><tr><td height=\"21px\" onMouseOver=\"this.className='yellowBG'\" onMouseOut=\"this.className='normal'\"><font class=\"navtext\"><a href=\"#\">Hardware Cleaning</a></font></td></tr><tr><td class=\"shader\"></td></tr><tr><td height=\"21px\" onMouseOver=\"this.className='yellowBG'\" onMouseOut=\"this.className='normal'\"><font class=\"navtext\"><a href=\"#\">Troubleshooting</a></font></td></tr><tr><td class=\"shader\"></td></tr><tr><td height=\"21px\" onMouseOver=\"this.className='yellowBG'\" onMouseOut=\"this.className='normal'\"><font class=\"navtext\"><a href=\"#\">Data Backup</a></font></td></tr><tr><td class=\"shader\"></td></tr><tr><td height=\"21px\" onMouseOver=\"this.className='yellowBG'\" onMouseOut=\"this.className='normal'\"><font class=\"navtext\"><a href=\"#\">Recovery Disks</a></font></td></tr><tr><td class=\"shader\"></td></tr><tr><td height=\"21px\" onMouseOver=\"this.className='yellowBG'\" onMouseOut=\"this.className='normal'\"><font class=\"navtext\"><a href=\"#\">Drivers Disk</a></font></td></tr><tr><td class=\"shader\"></td></tr></table>"
document.getElementById("navhead").innerHTML = "<font class=\"header\">Hardware/Software</font>"
break
case "virus":
document.getElementById("LEFTNAV").innerHTML ="<table align=\"left\" class=\"rpxtable\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td height=\"21px\" onMouseOver=\"this.className='yellowBG'\" onMouseOut=\"this.className='normal'\"><font class=\"navtext\"><a href=\"#\">Detection and Removal</a></font></td></tr><tr><td class=\"shader\"></td></tr><tr><td height=\"21px\" onMouseOver=\"this.className='yellowBG'\" onMouseOut=\"this.className='normal'\"><font class=\"navtext\"><a href=\"#\">Preventative Software</a></font></td></tr><tr><td class=\"shader\"></td></tr><tr><td height=\"21px\" onMouseOver=\"this.className='yellowBG'\" onMouseOut=\"this.className='normal'\"><font class=\"navtext\"><a href=\"#\">Adware / Spyware</a></font></td></tr><tr><td class=\"shader\"></td></tr><tr><td height=\"21px\" onMouseOver=\"this.className='yellowBG'\" onMouseOut=\"this.className='normal'\"><font class=\"navtext\"><a href=\"#\">Preventative Maintanence</a></font></td></tr><tr><td class=\"shader\"></td></tr></table>"
document.getElementById("navhead").innerHTML = "<font class=\"header\">Viruses</font>"
break
case "os":
document.getElementById("LEFTNAV").innerHTML ="<table align=\"left\" class=\"rpxtable\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td height=\"21px\" onMouseOver=\"this.className='yellowBG'\" onMouseOut=\"this.className='normal'\"><font class=\"navtext\"><a href=\"#\">Microsoft Windows</a></font></td></tr><tr><td class=\"shader\"></td></tr><tr><td height=\"21px\" onMouseOver=\"this.className='yellowBG'\" onMouseOut=\"this.className='normal'\"><font class=\"navtext\"><a href=\"#\">Linux</a></font></td></tr><tr><td class=\"shader\"></td></tr><tr><td height=\"21px\" onMouseOver=\"this.className='yellowBG'\" onMouseOut=\"this.className='normal'\"><font class=\"navtext\"><a href=\"#\">Macintosh</a></font></td></tr><tr><td class=\"shader\"></td></tr></table>"
document.getElementById("navhead").innerHTML = "<font class=\"header\">Operating Systems</font>"
break
case "webhelp":
document.getElementById("LEFTNAV").innerHTML ="<table align=\"left\" class=\"rpxtable\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td height=\"21px\" onMouseOver=\"this.className='yellowBG'\" onMouseOut=\"this.className='normal'\"><font class=\"navtext\"><a href=\"#\">Web Based Help Tickets</a></font></td></tr><tr><td class=\"shader\"></td></tr></table>"
document.getElementById("navhead").innerHTML = "<font class=\"header\">Online Help Tickets</font>"
break
case "webdes":
document.getElementById("LEFTNAV").innerHTML ="<table align=\"left\" class=\"rpxtable\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td height=\"21px\" onMouseOver=\"this.className='yellowBG'\" onMouseOut=\"this.className='normal'\"><font class=\"navtext\"><a href=\"#\">Logo Design</a></font></td></tr><tr><td class=\"shader\"></td></tr><tr><td height=\"21px\" onMouseOver=\"this.className='yellowBG'\" onMouseOut=\"this.className='normal'\"><font class=\"navtext\"><a href=\"#\">Web Scripting</a></font></td></tr><tr><td class=\"shader\"></td></tr><tr><td height=\"21px\" onMouseOver=\"this.className='yellowBG'\" onMouseOut=\"this.className='normal'\"><font class=\"navtext\"><a href=\"#\">Database Work</a></font></td></tr><tr><td class=\"shader\"></td></tr><tr><td height=\"21px\" onMouseOver=\"this.className='yellowBG'\" onMouseOut=\"this.className='normal'\"><font class=\"navtext\"><a href=\"#\">Layouts</a></font></td></tr><tr><td class=\"shader\"></td></tr><tr><td height=\"21px\" onMouseOver=\"this.className='yellowBG'\" onMouseOut=\"this.className='normal'\"><font class=\"navtext\"><a href=\"#\">Templates</a></font></td></tr><tr><td class=\"shader\"></td></tr><tr><td height=\"21px\" onMouseOver=\"this.className='yellowBG'\" onMouseOut=\"this.className='normal'\"><font class=\"navtext\"><a href=\"#\">Shopping Carts</a></font></td></tr><tr><td class=\"shader\"></td></tr></table>"
document.getElementById("navhead").innerHTML = "<font class=\"header\">Web Design</font>"
break
case "training":document.getElementById("LEFTNAV").innerHTML ="<table align=\"left\" class=\"rpxtable\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td height=\"21px\" onMouseOver=\"this.className='yellowBG'\" onMouseOut=\"this.className='normal'\"><font class=\"navtext\"><a href=\"#\">Windows OS</a></font></td></tr><tr><td class=\"shader\"></td></tr><tr><td height=\"21px\" onMouseOver=\"this.className='yellowBG'\" onMouseOut=\"this.className='normal'\"><font class=\"navtext\"><a href=\"#\">Universal Linux/Unix Training</a></font></td></tr><tr><td class=\"shader\"></td></tr><tr><td height=\"21px\" onMouseOver=\"this.className='yellowBG'\" onMouseOut=\"this.className='normal'\"><font class=\"navtext\"><a href=\"#\">Office Suites Training</a></font></td></tr><tr><td class=\"shader\"></td></tr><tr><td height=\"21px\" onMouseOver=\"this.className='yellowBG'\" onMouseOut=\"this.className='normal'\"><font class=\"navtext\"><a href=\"#\">PC Security</a></font></td></tr><tr><td class=\"shader\"></td></tr><tr><td height=\"21px\" onMouseOver=\"this.className='yellowBG'\" onMouseOut=\"this.className='normal'\"><font class=\"navtext\"><a href=\"#\">Preventative Maintanence</a></font></td></tr><tr><td class=\"shader\"></td></tr><tr><td height=\"21px\" onMouseOver=\"this.className='yellowBG'\" onMouseOut=\"this.className='normal'\"><font class=\"navtext\"><a href=\"#\">Heald College Cisco Certification</a></font></td></tr><tr><td class=\"shader\"></td></tr></table>"
document.getElementById("navhead").innerHTML = "<font class=\"header\">Training</font>"
break
default:
restoreNav();}
}
}
and the other function
var timer;
function restoreNav(){
{
stopDelay();
timer = setTimeout("restore()", 1250);
delete timer;
}
function restore()
{
if(document.getElementById && document.getElementById("LEFTNAV")) { //only restor nav if they are using IE5+ or NS6 or Some version of FireFox
document.getElementById("LEFTNAV").innerHTML = currentSection;
document.getElementById("navhead").innerHTML = currentHead;
}
}
function stopDelay(){
//clear the timer
if(typeof timer == 'undefined'){
//nothing to stop
}
else{clearTimeout(timer);}
}