|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2014-04-09 13:01 UTC] adrien dot dupuis at gmail dot com
Description: ------------ Hi, W/ Firefox 25.0.1, when an anchor link is clicked, the browser rightly scroll to it but it goes under the navbar so it's invisible. For example, in http://www.php.net/manual/fr/class.domdocument.php ; if you click the first "$actualEncoding" link, it seems to show the "config" property instead of the "actualEncoding" one because this wanted one is under #head-nav. Be aware that http://www.php.net/manual/fr/class.domdocument.php#domdocument.props.actualencoding directly pasted in the address bar doesn't behave the same as it corrects itself when DOM is ready. Best regards, Adrien PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 21:00:02 2025 UTC |
This seems to be the code that is supposed to do the job: //////////////////////////////// document.body.addEventListener("click", function (e) { if (e.target && e.target.nodeName === "A") { var href = e.target.getAttribute("href"); if (href && href[0] === "#") { var id = href.slice(1); var target = document.getElementById(id); // temporarily remove the id="" attribute so that the UA's // default scrolling is prevented target.id = ""; if (target) { PHP_NET.scrollElementIntoView(target, null, function () { // restore the id="" attribute target.id = id; }); } } } }); //////////////////////////////// This would work if the links were like <a href="#something">, but instead, they are like <a href="relative.path.of.current.page#something"> so, the javascript code does nothing at all in this case.