Skip to content

Instantly share code, notes, and snippets.

@patcullen
Created April 14, 2014 18:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patcullen/10672691 to your computer and use it in GitHub Desktop.
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.
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