Issue with javascript in the tableheader.js function. The dimensions plugin using 1.2 no longer has offset which was moved to the core. So when using offset on line 73
var scrollLocation = $('td'+ location.hash).offset().top - $(e).height();
It gives an error if the table is not currently pre-populated and the # is utilized in the query string when looking at comments for a node for instance.
The below code should resolve this issue.
var offset = $('td' + location.hash).offset();
if (offset) {
var top = offset.top;
var scrollLocation = top - $(e).height();
$('body, html').scrollTop(scrollLocation);
}
Comments
Comment #1
Dave ReidMarked #327292: Link to comment Disables Javascript as a duplicate of this issue. I can duplicate this issue on my own site. Just core Drupal, loading a page like http://mysite/node/1#comment-1 causes the error. I'll look into this more to see if this fixes the issue.
Comment #2
Flying Drupalist CreditAttribution: Flying Drupalist commentedI'll subscribe. Where does the code above go?
Comment #3
xmacinfoDave marked #302488: Fieldsets not expandable in Drupal 6.4 and up with a # in the URL Fieldsets not expandable in Drupal 6.4 and up with a # in the URL as a duplicate of this issue.
Comment #4
Dave ReidYou beat me to it! I also marked #328538: Broken code in tableheader.js as a duplicate of this issue.
Comment #5
xmacinfoWhich markup are you using to make the dup bug strikethrough? :-)
Comment #6
Dave ReidFrom the Input format help below..."Project issue numbers (ex. [#12345]) turn into links automatically." :)
Comment #7
darren.ferguson CreditAttribution: darren.ferguson commentedFile is tableheader.js on Line #73
Comment #8
Flying Drupalist CreditAttribution: Flying Drupalist commentedThank you so much darren.ferguson, works for me.
Comment #9
Flying Drupalist CreditAttribution: Flying Drupalist commentedI just want to report that Safari and Chrome are still broken.
Comment #10
whyameye CreditAttribution: whyameye commentedthis bug still exists in D6.8 and the code to fix still works (at least for FF3). Will this patch be incorporated in 6.9?
Comment #11
Manuel Garcia CreditAttribution: Manuel Garcia commentedJust wanted to confirm this is still an issue in 6.8
Comment #12
Gurpartap Singh CreditAttribution: Gurpartap Singh commentedStill applies in 6.9. This completely disables all the JavaScript when you visit a page with a fragment.
See http://myzonelabs.com/node/14#comment-138.
Can we get this fixed please?
Comment #13
Dave ReidLet's get a patch made so it can be properly reviewed.
Comment #14
Dave ReidComment #15
miglius CreditAttribution: miglius commentedI have attached the patch in the proper format.
Comment #16
Dave ReidComment #17
Dave ReidMarked #367088: tableheader.js error with anchors as a duplicate of this issue.
Comment #18
egfrith CreditAttribution: egfrith commentedThe patch at #325810-15: Issue when using dimensions jquery plugin in tableheader.js applies and works for me under FF 2.0.0.12. As far as I can see, the logic of it appears to be correct, and the coding style appears to be correct too.
Comment #19
hgmichna CreditAttribution: hgmichna commentedThis is probably no longer needed, but I'm posting it just in case as a reinforcement. The following happens in Internet Explorer 7 and Drupal 6.9.
Even if it can be avoided by improving Drupal, it does look superficially like a jQuery bug to me, and I've pondered the thought of reporting it as such. I think, no matter how the web pages are designed, jQuery should not crash like that.
http://winhlp.com/node/10#comment-869
Error in line 753: offset().top is null or not an object.
001:// $Id: jquery.js,v 1.12.2.3 2008/06/25 09:38:39 goba Exp $
002:
003:/*
004: * jQuery 1.2.6 - New Wave Javascript
...
749: // Check the previous anchor to see if we need to scroll to make room for the header.
750: // Get the height of the header table and scroll up that amount.
751: if (prevAnchor != location.hash) {
752: if (location.hash != '') {
753: var scrollLocation = $('td'+ location.hash).offset().top - $(e).height();
754; $('body, html').scrollTop(scrollLocation);
755: }
756: prevAnchor = location.hash;
757: }
Comment #20
radj CreditAttribution: radj commentedAdditional info:
It isn't just about comments. I think it's about the URL having an anchor in it. Javascript seems to go Off when in the following places:
www.site.com/node/32#test
www.site.com#any
But it doesn't occur if only the pound sign is there. ex:
1 - go to another site (ex: http://www.google.com)
2 - go to http://www.site.com# (note the extra #)
I intentionally did 1 to make sure that I visited the page, not just making the browser try to point to the anchor in the page.
Anyway, the result is, the site goes to "http://www.site.com/" -- the pound sign disappears and all JS is good.
Also, accessing http://www.site.com/# (slash then #) doesn't affect the JS, everything works fine.
Hope this info helps.
Using D6.9
EDIT -- and the patch in #15 fixes it.
Comment #21
xmacinfoReported this bug to the DO webmasters -> #394098: Some JavaScript disabled if a pound sign is present in the URL
Comment #22
Damien Tournoud CreditAttribution: Damien Tournoud commentedThis affects d.o badly too.
Comment #23
Gurpartap Singh CreditAttribution: Gurpartap Singh commentedComment #24
webchickDamien checked and this does not appear to affect 7.x since we now use jQuery 1.3 and presumably it became smarter some time. Or else we accidentally fixed this as part of the changes necessary to get Drupal 7 to work with jQuery 1.3.
In any case, this only needs fixing in 6.x. :) But fixing it on d.o ASAP would be a good and wonderful thing.
Comment #25
cwgordon7 CreditAttribution: cwgordon7 commentedI tested this bug at admin/build/modules#system-modules on a fresh drupal 6-dev installation, javascript was broken on the entire page with the anchor, but worked fine without it. After the patch was applied, it worked smoothly both ways. I tested on the browsers currently available to me, which happened to be firefox 3 and konqueror, and the patch worked for both of them. Along with the comments in #18, I think this is rtbc.
Comment #26
richguynextdoor CreditAttribution: richguynextdoor commentedThis same issue existed for me in drupal 6.10. When a file was attached to a node it would break the javascript when trying to add a comment. The FCKeditor would not overlap the current text box, and the input option menu would no longer be expandable.
I applied the patch referenced in comment #15 and it fixed the issue for both Firefox 3.0.7 and internet explorer 8.
Comment #27
bob.hinrichs CreditAttribution: bob.hinrichs commentedsubscribe. getting same error using Drupal 6.10
Comment #28
cwgordon7 CreditAttribution: cwgordon7 commentedSince this issue still exists in the development version, it is listed under the development version and not any specific release.
Comment #29
webchickw00t!! David Strauss applied this to d.o and it works great. :) (your squid timeout may vary)
Removing drupal.org upgrade tag, still needs committing to 6.x proper.
Comment #30
Gábor HojtsyCommitted to Drupal 6. Thanks!
Comment #31
markus_petrux CreditAttribution: markus_petrux commentedFix not committed too HEAD.
Comment #32
Dave ReidSee #24: "Damien checked and this does not appear to affect 7.x since we now use jQuery 1.3 and presumably it became smarter some time. Or else we accidentally fixed this as part of the changes necessary to get Drupal 7 to work with jQuery 1.3."
If you can confirm this is still a problem on HEAD, go ahead and re-open this.
Comment #34
rgarand CreditAttribution: rgarand commentedUnfortunately there is still a related error. I recently found that sharing links on Facebook adds a hash to them like #.TlfKSwI4roo.facebook which causes a jQuery error, so anyone who clicked on the link would get a page with no Javascript. Further testing has shown that the first . is the cause of the error. This might be a fairly simple case to detect and correct in the tablesort file.
Comment #35
rgarand CreditAttribution: rgarand commentedComment #36
rgarand CreditAttribution: rgarand commentedAfter external fixes in the theme proved to be unreliable, I changed line 72 of tableheader.js to the following which corrected the error:
if (location.hash != '' && location.hash.indexOf('.') != 1) {
Comment #37
xmacinfoFor your patch.
Comment #39
xmacinfoWe probably need to tell the bot to test against 6.x-dev.
Did you roll your patch against 6.x-dev?
Comment #40
rgarand CreditAttribution: rgarand commentedIt's from 6.19 but it was generated by Windiff so it may be the patch format...
Comment #41
xmacinfoYou need to roll against the 6.x-dev or the bot will fail.
Comment #42
Leksat CreditAttribution: Leksat commentedThe main problem is sitting here:
Variable "offset" always equals to "true" because it is an object. If $('td' + location.hash) doesn't exist, "offset" is "{top=0, left=0}". So, first we should do is check whether $('td' + location.hash) exists on the page:
Comment #43
Leksat CreditAttribution: Leksat commentedI think I found more beauty way.
Comment #44
Leksat CreditAttribution: Leksat commentedPatch from #43 updated to work with Jquery 1.7 (#1067290: Fix jQuery 1.7 for Drupal 6).
Comment #45
kentr CreditAttribution: kentr commented#44 fixed the issue for me, on D6 with jQuery 1.3
Patch didn't apply, though. I seem to recall that Drupal specs for patches are that they should be rolled from with the directory of the file being patched (or, relative to that directory). Looks like perhaps this one wasn't.
Comment #46
acbramley CreditAttribution: acbramley commentedThis issue is still present in 6.34, my issue is it completely stops anchor links working on first click, and stops anchors from other pages working at all. I get no JS console errors though
The patch in #44 no longer applies, here's a slightly more simple, rerolled version against the latest 6.x HEAD, it seems to fix my issues and follows what the patch in #44 was achieving.