open al external link in new window


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

parse every anchor (<a href="#"></a>) on your page


Copy this code and paste it in your HTML
  1. // Open external links in new windows using jquery
  2. $('a[href^="http://"]').filter(function() {
  3. return this.hostname && this.hostname !== location.hostname;
  4. }).attr('target', '_blank');

URL: http://www.andrewgreig.com/2010/05/use-jquery-to-open-all-external-links-in-a-new-window/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.