Click to See Complete Forum and Search --> : Jscript and Netscape7.0


ptik
02-19-2003, 01:24 AM
I've realised dropdownmenu. It work good with IE5, Opera6 and 7, and (!!!) Netscape 4.7, BUT my menu doesn't drop with Netscape 7.0. Why? Please, help if your know something about.

gil davis
02-19-2003, 05:54 AM
Post your code.

ptik
02-19-2003, 06:05 AM
<!--
function showLayer(layerName){
if(document.layers&&document[layerName]) {
document.layers[layerName].visibility='visible';
} else if(document.all&&document.all[layerName]) {
document.all[layerName].style.visibility='visible';
}
}

function hideLayer(layerName){
if(document.layers&&document[layerName]) {
document[layerName].hidden=true;
} else if(document.all&&document.all[layerName]) {
document.all[layerName].style.visibility='hidden';
}
}

function menuOn(tdname, parent) {
ResetCloseTimeout();
if (!parent) { SetOpenTimeout(tdname); }
}

function menuOff(tdname, parent) {
if(!parent) { ResetOpenTimeout(); }
SetCloseTimeout(tdname);
}

var closeTimeout, openTimeout;

function SetOpenTimeout(item) {
clearTimeout(openTimeout);
openTimeout = setTimeout("onOpenEvent('" + item + "')", 150);
}

function ResetOpenTimeout() { if(openTimeout) clearTimeout(openTimeout); }

function SetCloseTimeout() {
clearTimeout(closeTimeout);
closeTimeout = setTimeout("onCloseEvent()", 150);
}

function ResetCloseTimeout() {
if(closeTimeout) clearTimeout(closeTimeout);
}

function onOpenEvent(item) {
ResetCloseTimeout();
onCloseEvent();
showLayer('m' + item);
}

function onCloseEvent() {
for (var i=1; i<=5; i++) hideLayer('m'+i);
}

gil davis
02-19-2003, 06:55 AM
I do not believe that the code you posted will work in NS 6 either. You are testing for NS 4 (document.layers) and IE (document.all) and thus eliminating NS 6 and NS 7 as well as any W3C DOM compliant browsers.

function showLayer(layerName) {
if (document.getElementById)
{document.getElementById(layerName).style.visibility = "visible";}
else
{if (document.layers)
{document.layers[layerName].visibility = "show";}
else
{if (document.all)
{document.all[layerName].style.visibility = "visible";}
}
}
}

function hideLayer(layerName) {
if (document.getElementById)
{document.getElementById(layerName).style.visibility = "hidden";}
else
{if (document.layers)
{document.layers[layerName].visibility = "hide";}
else
{if (document.all)
{document.all[layerName].style.visibility = "hidden";}
}
}
}

ptik
02-19-2003, 08:41 AM
to gil davis

I tried use your code and my editor (HTML-kit) informed about mistake.
I modified code to:

if(document.layers&&document[layerName])
if(document.all&&document.all[layerName])
if (document.getElementById&&document[layerName] )

It began work in IE but not in NS

Regrettably, I don't understand how JS code works in this strings
because I'm not JS-programmer.

May be you can correct third string and

THANK YOU VERY MUCH FOR YOUR TIME

rubi
02-19-2003, 01:29 PM
hello,
try to use sth like this:
i don't know why in newest versions of NS we can't (or don't know) get elements by using document and layers objects...
But we can access layers by getting object by Id (every layer has or should have own ID):
try to use code like gil's code:

in HTML:
<div id="myLayerName" style="bla bla :)"></div>


in JS:
the same code for IE, NS6, 7 (mozilla):
myLayer = document.getElementById("myLayerName").style;

and for NS4
myLayer = document.myLayerName;

and then;
myLayer.visibility = "visible";

it works (i've done it today at work - but there were maaaany problems with it ;)))))))

CU