How to open ALL external web sites or references in a NEW window?

Using JQuery to open external links in new windows

Earlier we used to write a string of code in javascript to enable opening external references in a new window in addition to modifying the html code

With JQuery, this can be done with one line of code as shown below


The above line checks for occurences http in a tag and if a link has “http” in it, JQuery opens the link in a NEW window.

According to W3C standards, the target attribute has been removed from xhtml 1.1 specification.

Sample script to open external links in New Window

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "">
<html xmlns="" xml:lang="en-GB">
<script src="js/jquery-1.3.2.min.js" type="text/javascript"></script>
<script language="javascript">

Testing the pages - Open Links in new <a href="">window</a>.

<h1><a href="">Kurinchilion</a></h1>
Share it onShare on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn

Written by kurinchilamp

Website: http://

Leave a Reply

Your email address will not be published. Required fields are marked *

Read previous post:
CakePHP: NuSoap web service call configuration

This is a beginner tutorial to help beginners make a call to "wsdl" files and for them to display the...