Closed (fixed)
Project:
MySite
Version:
5.x-3.0beta3
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
28 Jan 2008 at 15:34 UTC
Updated:
22 Feb 2008 at 01:11 UTC
When viewing a page without any mysite-links in IE7 I get the javascript error message: 'document.getElementById(...)' is null or not an object. This is caused by the first line in the mysiteHover function.
mysiteHover = function() {
sfEls = document.getElementById("mysite-links").getElementsByTagName("LI");
Comments
Comment #1
agentrickardTwo issues here, and a request.
1) Why is mysite_links.js being loaded on pages where no links exist? The
mysite_linkfunction wraps itself in the following IF:So on what pages (Drupal paths) are these occurring?
2) I do not have IE 7. So what is the recommended fix?
Comment #2
gustav commentedThis is happening on node pages that use a template that does not show the node links. The template distributed with the organic groups module for use with organic group home pages is an example.
I think the fix would be to put a check into the javascript to see if the element actually exists. However I am not a javascript programmer.
Comment #3
agentrickardTry replacing the existing code with this:
Comment #4
gustav commentedThe problem is that the getElementByID() is empty, so that an error is thrown already before sfEls is calculated. This code does not fix that.
Comment #5
agentrickardOK. Not sure what do do about IE stupidity here. Try this.
Comment #6
agentrickardOr better. Go test these sample and report which one works.
http://www.htmldog.com/articles/suckerfish/dropdowns/
Comment #7
gustav commentedThis comes close. However you do not want to check for the empty string. Instead you want to check that the variable is not Null. Apparently, javascript makes a distinction there, unlike PHP. Also there should only be a single = in var sfE1s = ''
The following works in IE7:
However, as I said, I don't know javascript, and so I don't know whether the above will work in all browsers.
Comment #8
agentrickardI am rather shocked that it worked in IE7. My guess was that it did not like being asked to evaluate the TagName after not finding the parent Element.
It should be fine in other browsers. Will test.
This affects 5.x.2 as well.
Thanks.
Comment #9
agentrickardWorks in FF / Mac and Safari / Mac. So considering harmless.
Comment #10
agentrickardCommitted to HEAD. Thanks for the debugging support!
Comment #11
agentrickardBackported to 5.x.2.
Comment #12
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.