Automatically use jQuery to Open External Links in New Window (checking domain first)


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

Automatically use jQuery to Open External Links in New Window (checking domain first).


Copy this code and paste it in your HTML
  1. // open external links in new window (checking domain first)
  2. jQuery("a[href^='http']:not([href*='" + document.domain + "'])").each(function () {
  3. jQuery(this).attr("target", "_blank");
  4. });

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.