Forum Moderators: open
I have a web page that uses javascript to provide popup menus. These menus have been working beaut until part of our org started using Netscape 7.1. Now the page that has the menus on it blinks on when first loaded but disappears into the ether for ever after that. The javascript console indicates an error message that a function used in the script is not defined.
The function seems to be defined (note I am not a javascript guru) and is called a number of times during the script. The javascript error reported is on the line that the first call is made.
Before I post a swag of code is there something fundamental I am overlooking. I have only recently found your site but have searched thru a number of posts but as yet haven't found anything regarding specific compatibility issues between 4.x and 7.1 versions
I assume you're using document.all (which works in IE4+) and document.layers (which is NN4 only) in your JavaScript. Consider using document.getElementById, which is the prefered method for all browsers that support it.
Something like this would work:
if(document.getElementById) {
//DOM compliant browser
}
else if(document.all) {
//old IE
}
else if(document.layers) {
//NN4
}
*
*
function lookfor(item) {
if (document.all) return(document.all[item]);
if (document.getElementById) return (document.getElementById(item));
return false;
}
*
*
function writMenus(container) {
if (window.triedToWriteMenus) return;
if (!container && document.layers) {
window.delayWriteMenus = this.writeMenus;
var timer = setTimeout('delayWriteMenus()',250);
container = new Layer(100);
clearTimeout(timer);
}else if (document.all ¦¦ document.hasChildNodes){
document.writeln('<SPAN ID="menuContainer"></SPAN>');
container = lookfor("menuContainer");
}
*
*
The javascript console is indicating an error on the line where the lookfor function is called. Any suggestions?