Closed Bug 125318 Opened 24 years ago Closed 23 years ago

JavaScript Menu not working

Categories

(Core :: DOM: Core & HTML, defect, P2)

defect

Tracking

()

RESOLVED FIXED
mozilla1.4alpha

People

(Reporter: info, Assigned: jst)

References

()

Details

(Whiteboard: [HAVE FIX])

Attachments

(3 files)

Hovering over top menu should show up pull-downs
May be evangelism. The browser sniffing feeds the browser either http://www.volvooceanrace.org/scripts/menu/iemenu.js or nsmenu.js The "NS" file is served to NN4 only. Moz gets the "IE" file, which has calls to both document.all and document.getElementById(), so it's possible that it's intentional that Moz gets the IE file. Unfortunately, both those JS files are deliberately obfuscated, so figuring out what's happening isn't going to be easy. Confirming. I'm going to try and descramble iemenu.js a bit, and see what I can find...
Status: UNCONFIRMED → NEW
Ever confirmed: true
Curiously, the iemenu.js file ALSO has document.layer calls. I'm no JS whiz, but I managed to descramble the file a bit (I'll attach it in a mo, so that any interested JS gurus can try to work out what's going on. Mousing over the menubar gives "Error: mFrame has no properties Source File: http://www.volvooceanrace.org/scripts/menu/iemenu.js Line: 1"
Gavin, thank you for descrambling the JS file! Thanks to you, I was able to debug it. I see two problems: 1. When you load the site, you see this error in the JS Console: Error: setting a property that has only a getter Source File: http://www.volvooceanrace.org/scripts/menu/iemenu.js Line: 1 Note it says "Line:1" because the file is obfuscated: all on one line! Thanks to Gavin, we find where the error is : var BV=navigator.appVersion; BV=parseFloat(BV.indexOf('MSIE')>0? BV.split(';')[1].split(' ')[2] : BV.split(' ')[0]); var BN=window.navigator.appName; var IsWin=(navigator.userAgent.indexOf('Windows')!=-1)?true:false; var OP=(navigator.userAgent.indexOf('Opera')!=-1&&BV>=4)?true:false; var SM=(BN.indexOf('Netscape')!=-1&&(BV>=5)||OP)?true:false; var NS=(BN.indexOf('Netscape')!=-1&&!SM)?true:false; var IE=(BN.indexOf('Explorer')!=-1&&(BV>=4)||SM)?true:false; if((!IsWin&&IE)||SM) { frames.self=window; <<<<<<<<<<<<<<<<<<<<<<<<<<<<< ERROR OCCURS HERE frames.top=top; } Note: in Mozilla |SM| evaluates to true, so we DO hit this line - 2. The menu items at the top of the page are "HOME", "NEWS", etc. These are accessed in the code via mFrame.document.getElementById('Home'); etc. Now, |mFrame| is null as Gavin pointed out in Comment #2. To make a long story short, |mFrame| is supposed to be the Window object, so this can be reduced to: document.getElementById('Home'); But: load the site and try this in the URL bar: javascript: alert(document.getElementById('Home') === null); In IE6, you get 'false', in Mozilla you get 'true' So in Mozilla, none of the menu code is going to work.
The |frames.self=window;| error above is the reason |mFrame| evaluates to null in Mozilla, as far as I can see. The problem occurs here: function SetUpEvents() { onerror=errHandler; if(typeof(mFrame)=="undefined") mFrame=eval(frames['self']); <<<<<<<<<<<<<< null BECAUSE OF ABOVE ERROR if(typeof(mFrame)=="undefined") <<< typeof(mFrame)== typeof(null)== "object" { window.setTimeout("SetUpEvents()",10); <<< so we don't fall into here } else { if(NS) { mFrame.captureEvents(Event.MOUSEMOVE); mFrame.onmousemove=HideMenus; PrepareEvents(); } if(IE) { document.onmousemove=HideMenus; mFrame.document.onmousemove=document.onmousemove; } } }
Reassigning to DOM Level 0, because these are DOM issues, not JS Engine. As outlined in Comment #4 above, we have two separate problems: 1. Why does |frames.self = window| trigger an error in Mozilla but not in IE6? 2. Why is document.getElementById('Home') === null in Mozilla, but not in IE6? Problem 1 causes the variable |mFrame| to be null, which ruins their whole menu DHTML. However, even if we set |mFrame = this| in the JS Debugger, so that it is the global Window object it is supposed to be, the DHTML menus fail because of Problem 2.
Assignee: rogerl → jst
Component: JavaScript Engine → DOM Level 0
QA Contact: pschwartau → desale
*** Bug 103112 has been marked as a duplicate of this bug. ***
As you probably can see by now we're using the commercial DHTML MenuBuilder from xFX software (http://software.xfx.net/mainindex.htm) for this, and we've not seen many other problems before with their code. I have been using build 2001031614 of Mozilla for testing (out-of-the-box RH7.1 distribution) and haven't come up against any problems with the menu code. Interestingly they say that their code is compatible with Mozilla 0.6 on their product description. While I can see there's a problem here not so much with our page/code but with the DOM, if anyone has a suggestion how we can keep our Mozilla fans happy I'd be happy to try and implement it.
Darren: thanks. Using Mozilla binary 2002021413 on WinNT, 1. I went to that site, http://software.xfx.net/mainindex.htm. 2. I clicked on "Public Forum", which led me to: http://software.xfx.net/uboards/indexp.php?forum=uboard_main.htm 3. I moused over the "DHTML Menu Builder" link 4. CRASH!!! But that looks like a different issue than here. The stack trace is almost identical to the one posted at Bugzilla bug 123803: http://bugzilla.mozilla.org/attachment.cgi?id=68162&action=view
Blocks: 113492
frames.self=window fails in Mozilla because nsIDOMWindowInternal::Self is a readonly attribute (which is why it says setting a property that only has a getter). The MSDN library says it is also readonly in IE (http://msdn.microsoft.com/library/default.asp?url=/nhp/Default.asp?contentid=28000441) Not sure about the second error.
Is this problem still occuring as I can't see any of the messages mentioned on BuildID 2003020308 on WinXP SP1
Ian: The site has been changed, the event is over for some months. There are no pull-downs now. Think we should close this or find a similar bug to track this. Johnny?
Sounds like we can't do much more than fix the one problem we know about here for now, this patch makes window.self (and thus also frames.self) settable.
Attachment #114989 - Flags: superreview?(peterv)
Attachment #114989 - Flags: review?(fabian)
Status: NEW → ASSIGNED
Keywords: 4xp
OS: Windows 98 → All
Priority: -- → P2
Hardware: PC → All
Whiteboard: [HAVE FIX]
Target Milestone: --- → mozilla1.4alpha
Forgot this in the first diff, just adding a comment...
Attachment #114990 - Flags: superreview+
Attachment #114989 - Flags: superreview?(peterv) → superreview+
Comment on attachment 114989 [details] [diff] [review] Fix the window.self='...' problem. how many non-settable properties are non-replaceable now? wouldn't it make sense to implement a general mechanism that all non-settable properties are replaceable? If not, r=fabian.
Attachment #114989 - Flags: review?(fabian) → review+
Attachment #114990 - Flags: review+
Fabian, that's an idea to think about, but for now I'm not up for doing that. Please feel free to file a bug on that though. FIXED.
Status: ASSIGNED → RESOLVED
Closed: 23 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: