Open external links in a new window

26th September 2013
The following little bit of jQuery will open all external links in a new window.


First we get all links that starts with http (this will include links going to secure sites, https).
Then remove any links that contain the host name for the site you are on.
This leaves only external links, so we add "_blank" to the target attribute, which will open the link in a new window.