Forked from jkphl/Highlight non-matching anchor links (Bookmarklet)
Created
January 2, 2020 07:26
-
-
Save helix84/a6127b7b5a7f635819ba0190fb00ca84 to your computer and use it in GitHub Desktop.
Use this JavaScript bookmarklet to find invalid anchor references within your HTML documents. The script searches the current document for links referring to named anchors on the same page that don't really exist and highlights them with a red background.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(function(){for(var a=0,anchors=document.querySelectorAll("a[href^='#']"),al=anchors.length,anchor;al>a;++a)anchor=anchors[a].href.split("#").pop(),anchor.length&&!document.getElementById(anchor)&&(anchors[a].style.color="#fff",anchors[a].style.backgroundColor="#f00")})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment