Welcome to WebmasterWorld Guest from 18.208.187.169

Forum Moderators: open

Message Too Old, No Replies

Javascript works in 4.7x but not in 7.1

Javascript problem

     
5:46 am on Nov 14, 2003 (gmt 0)

New User

10+ Year Member

joined:Nov 14, 2003
posts:2
votes: 0


My initial post so please be kind.

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

6:23 pm on Nov 14, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member drdoc is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 15, 2002
posts:6807
votes: 0


Welcome to Webmaster World!

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
}

6:23 am on Nov 17, 2003 (gmt 0)

New User

10+ Year Member

joined:Nov 14, 2003
posts:2
votes: 0


The code I am using does use the "getElementById" within the function. But the problem reported by the Javascript console is that the function is not defined. I have included the function code and the first call to that function below, this may make it a bit clearer.

*
*
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?