Hi,
The following piece of code in tableheader.js causes javascript error $("td" + location.hash).offset() is undefined when a hash is present in the URL that has no relation with table cells.
if (prevAnchor != location.hash) {
if (location.hash != '') {
var scrollLocation = $('td' + location.hash).offset().top - $(e).height();
$('body, html').scrollTop(scrollLocation);
}
prevAnchor = location.hash;
}
The error happens when the selector 'td' + location.hash does not match any element. In that case, offset().top is undefined.
I think it could be fixed by adding a condition like this:
if (prevAnchor != location.hash) {
if (location.hash != '' && $('td' + location.hash).size()) {
var scrollLocation = $('td' + location.hash).offset().top - $(e).height();
$('body, html').scrollTop(scrollLocation);
}
prevAnchor = location.hash;
}
I'm making the issue critical because this issue causes javascript errors when a hash is present in the URL that does not match a TD identifier. This javascript error breaks all the javascript present in the site, including ads, analytics, etc.
Please, consider backporting this fix to D6 too.
Comments
Comment #1
markus_petrux commentedI guess this probably needs to be fixed first in dev. Attached patch against HEAD.
Comment #3
markus_petrux commentedwow! and now? Why the patch failed?
hmm... adding -p option to the diff command to see if that helps.
Comment #5
markus_petrux commentedhmm... this is kind of frustrating, isn't it? All you can see here is that the patch fails, but it doesn't tell you why.
I hate to turn this into a support question, but can someone drive me in the correct direction?
Comment #6
markus_petrux commentedDup: #325810: Issue when using dimensions jquery plugin in tableheader.js