Index: common/wikibits.js =================================================================== --- common/wikibits.js (revision 16963) +++ common/wikibits.js (working copy) @@ -518,20 +518,11 @@ var link = el.childNodes[i]; if (link.nodeType == 1 && link.nodeName.toLowerCase() == 'a') { var editHref = link.getAttribute('href'); - - // find the following a - var next = el.nextSibling; - while (next.nodeType != 1) - next = next.nextSibling; - - // find the following header - next = next.nextSibling; - while (next.nodeType != 1) - next = next.nextSibling; - - if (next && next.nodeType == 1 && - next.nodeName.match(/^[Hh][1-6]$/)) { - next.oncontextmenu = function() { + // find the enclosing (parent) header + var prev = el.parentNode; + if (prev && prev.nodeType == 1 && + prev.nodeName.match(/^[Hh][1-6]$/)) { + prev.oncontextmenu = function() { document.location = editHref; return false; }