Posted By

relaxasaurus on 02/17/10


Tagged

link window jquery new external


Versions (?)

Open external links in new window without target = _blank using jQuery


 / Published in: JavaScript
 

  1. $(document).ready(function() {
  2. externalLink();
  3. });
  4.  
  5. function externalLink() {
  6. $("a[@href^=http]").each(
  7. function(){
  8. if(this.href.indexOf(location.hostname) == -1) {
  9. $(this).attr('target', '_blank');
  10. }
  11. }
  12. )
  13. };

Report this snippet  

You need to login to post a comment.