Created
April 14, 2014 18:38
-
-
Save patcullen/10672691 to your computer and use it in GitHub Desktop.
A snippet of JS to test how many links follow to a new target.
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
console.log('Location:', '' + window.location); | |
console.log('Number of links:', document.querySelectorAll('a').length); | |
console.log('Number of _blank links:', document.querySelectorAll('a[target="_blank"]').length); | |
console.log('% of _blank links:', ~~( document.querySelectorAll('a[target="_blank"]').length / document.querySelectorAll('a').length * 100 ) ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment