diff --git a/boards/static/js/refpopup.js b/boards/static/js/refpopup.js --- a/boards/static/js/refpopup.js +++ b/boards/static/js/refpopup.js @@ -46,8 +46,9 @@ function addRefLinkPreview(node) { function showPostPreview(e) { var doc = document; - //ref id - var pNum = $(this).text().match(/\d+/); + + var reflink = $(this); + var pNum = reflink.text().match(/\d+/); if (pNum == null || pNum.length == 0) { return; @@ -57,8 +58,8 @@ function showPostPreview(e) { if (post.length > 0 && isElementInViewport(post)) { post.addClass('highlight'); } else { - var x = e.clientX + (doc.documentElement.scrollLeft || doc.body.scrollLeft) + 2; - var y = e.clientY + (doc.documentElement.scrollTop || doc.body.scrollTop); + var x = reflink.offset().left; + var y = reflink.offset().top; var cln = doc.createElement('div'); cln.id = 'pstprev_' + pNum;