Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

works in IE, not Netscape

Status
Not open for further replies.

ruz

Programmer
Jul 13, 2001
3
US
This is odd, i've looked over the code several times and i can't figure out why it is working in IE and not Netscape. Basically, this is a script that allows a layer to open (used like a menu). it works across frames (the layer opens in the window created by the rest of the html in this page) and opens on a graphic click. that works. then if the frame scrolls, it allows the opened layer to move (floating layer) up/down dependent on scrollbar position. Now, here's the problem. when i click on one menu (there are only 2) it opens. then click on the other, the 1st closes and the 2nd opens. good. however, if i click the 2nd one again, when it is supposed to close, it doesnt!!! good news is, it works for internet explorer exactly the way i described. okay, enough explaining, here is the code.

Code:
        function posLayer(layerName) {
                if (navigator.appName == "Netscape") {
                        yPos = parseInt(window.pageYOffset);
                } else {
                        yPos = document.body.scrollTop;
                }
                eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.top = yPos');
        }

        function showHideLayerSwitch(layerName) {
                clearInterval(killID);

                if(eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility=="visible"')) {
                        eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="hidden"');
                } else {
                        if (navigator.appName == "Netscape") {
                                yPos = parseInt(window.pageYOffset);
                        } else {
                                yPos = document.body.scrollTop;
                        }
                        eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.top = yPos');
                        killID = setInterval('posLayer("'+layerName+'")', 250);
                        eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="visible"');
                }
        }

thank you very much for your time. i'm hoping someone out there is able to understand how the above code is interpreted in both browsers...
 
If you're having problems in netscape, I would say that it is due to their insufficient usage of style. I usually have problems w/ the style element in NN. I'll see if I can work out something that will work for both.
 
I'm baffled. I have a hunch its to do with how netscape reads and writes the visibility property. When I create layered menus I usually set them all to visible at the start and then hide/show them by changing the clipping. This seems to work ok. I dont think your code would need to be modified too much to do this.
Sorry I cant be more helpful ASCII silly question, get a silly ANSI
 
hey all,

thanks for your replies...but i think i figured out how to stop it from doing this...

here is a code snippet that is part of the above. after looking closely, the only difference is the substitution of 'visibleVar'. this has been sent (during init()) to "show":

Code:
        function showHideLayerSwitch(layerName) {

                if(eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility==visibleVar')) {
                        eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="hidden"');

now, don't ask me WHY this works, but for some reason it does...and i thought netscapes visibility method was set using the strings "visible" (not "show") or unset with "hidden" (there are others) but for some reason, visibleVar must be set to "show". as you can tell, i am not the author of 100% of this code, i just took someone a tutorial script, fiddled withit and got it to do what i want it to. it was originally to scroll layers or something, i forget now, but i liked the eval statements for cross-browser works...etc

o well, i just didn't want anyone to try to search for more answers.

but onto another question - i'm trying to work with event handlers - i want to get the layer to disappear when i click anywhere in the document (not on a link of course in that layer). it works, again, perfectly fine in IE with <BODY onMouseDown=&quot;hideAll();&quot; , where hideAll hides the two layers...

now, in netscape that tag doesnt exist. so in init() i set up an event listener:

Code:
                        document.captureEvents(Event.MOUSEDOWN);
                        document.onmousedown = hideAll;

this is equivalent to IE right? wrong. it works the same way if you click on the document. but here's where it is different - if you click on the scrollbar in netscape, it does NOT disappear, whereas in IE it does. so - is there an event listener i could also listen to for mousedown events on the scrollbar? i prefer mousedown, not onclick, because i want it to disappear the fastest.

thanks, and sorry for the length,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top