Valid External Links


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <script type="text/javascript">
  2. function externalLinks() {
  3. if (!document.getElementsByTagName) return;
  4. var anchors = document.getElementsByTagName('a');
  5. for each (anchor in anchors) {
  6. if (anchor.getAttribute('href') && anchor.getAttribute('rel') == 'external') {
  7. anchor.target = '_blank';
  8. }
  9. }
  10. }
  11.  
  12. window.onload = externalLinks;
  13. </script>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.