jQuery compliant target="blank" effect for all links

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

Copy this code and paste it in your HTML
  1. //Open External Links in New Window
  2. $('a[href^="http://"]') .attr({ target: "_blank" }); //Makes all links open in a new window
  3. $('a[href^="http://"].target') .attr({ target: "_blank" }); //a link with the class of "target" opens in a new window

URL: http://www.sohtanaka.com/web-design/jquery-easy-tips-tricks-tutorial/

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.