PDA

View Full Version : JavaScript rocks my world :)


the_pm
November 30th, 2004, 20:35
Yeah, I know all of the pitfalls associated with JavaScript, but I think my latest version of the collapsing menu is the best, most efficient I've done yet. Now, there's just one problem:

In Opera, the menu that's open refuses to close. Originally, I only showed the active menu via CSS and an id in the <body> tag. I added the onload event so that you wouldn't have to double click the already-open menu to get it to close. Apparently, not doing this meant the menu was not in "DOM mode," and was recognized as being closed by the script even those it was blatently open.

But for some reason, the Opera onload event handler seems to override the script! Anyone have any answers for that one?

http://plhmedia.com/ex/hideaway_menus/1-1.html

Try it in IE abd Moz/FF to see how it should act, then try Opera. Weird, eh?

the_pm
November 30th, 2004, 20:41
Oh yes, the reason I've created this version is because shortly it is going to become a tutorial/open script for everyone's use, and I want to iron out the bugs. This is that script I've been promising, so please help with this little detail!

Anoop
December 6th, 2004, 17:47
HI..
I think the problem is with the style of body. Can you remove
id="category2" from the body tag and try again with opera.. The menu will work
I think then you will be able to correct the body style

-Anoop

the_pm
December 6th, 2004, 18:03
Thanks Anoop :)

The reason that is there is so that the correct category expands automatically when JavaScript is disabled, depending upon in which section the page resides. I notice that when I set this using JavaScript as an onload function and remove the id, it works fine in Opera, but then you lose the noscript functionality inherent in its design. So basically the body tag id must remain, or must be generated reliably in such a way that it works with JS disabled, but doesn't override the DOM function meant to open/close it.

Is this a browser bug? Should I submit this to Opera? Or is this a perfectly legitimate interpretation of ECMA standards (something I'm reluctant to delve into...)?

Anoop
December 7th, 2004, 05:59
Can you just try one more thing... Make a slight modification in the following line

#category1 #menu1, #category2, #menu2 { display:block }
I put a " , " after #category2 which is the only difference from ur original code. I'm not an expert in these, anyway. Just trial and error method :D

-Anoop

the_pm
December 7th, 2004, 06:05
Hmm, that would cause #menu2 to be a block-level element at all time, instead of just when the body is IDed as category2. That little bit of code makes the right menu category spring open. The menu is functioning in a test environment right now, it you'd like to see it:

http://www.gasserjewelers.com/test/index.asp - See how the Home menu is open?
http://www.gasserjewelers.com/test/showroom/index.asp - Now the Showcase menu should be open.

This is exactly what should happen with JavaScript disabled too, only the extra expansion features are lost, of course, a nice and graceful degradation. But that pesky Opera...

Anoop
December 7th, 2004, 06:26
Opera always shows some problem with javascript .. Sometimes it works a different way than with other browsers. Almost everything in javascript will work as we expect, with Mozilla ... Other browsers may act different on the same javascript code, which is my experience ... :(

the_pm
December 7th, 2004, 06:31
Shame. It's commonly held that IE has a highly flawed DOM interpretation, but it's always a little disheartening to hear your favorite browser has a flaw. Maybe it's fixed in a newer version (I'm running 7.23). If not, I think I'll submit this to them to see how they respond. Thanks again Anoop :)

Anoop
December 7th, 2004, 06:43
Yea ..It's better to submit this to them. Mine is Version 7.50 (for linux)

websterworld
December 7th, 2004, 11:56
Shame. It's commonly held that IE has a highly flawed DOM interpretation, but it's always a little disheartening to hear your favorite browser has a flaw. Maybe it's fixed in a newer version (I'm running 7.23). If not, I think I'll submit this to them to see how they respond. Thanks again Anoop :)

Duh'! Paul you should upgrade to 7.54.

the_pm
December 7th, 2004, 12:08
Shame. It's commonly held that IE has a highly flawed DOM interpretation, but it's always a little disheartening to hear your favorite browser has a flaw. Maybe it's fixed in a newer version (I'm running 7.23). If not, I think I'll submit this to them to see how they respond. Thanks again Anoop :)

Duh'! Paul you should upgrade to 7.54.
Yes, I should, but I'm waiting for 7.56 :)