This version uses jQuery which I use on a lot of projects.
The simplest use without downloading anything is this.
Before your closing head tag,
1 |
</head> |
Add
1 2 3 4 5 6 7 8 9 |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script> $(document).ready(function(){ //new window method for external links $('a.external').click(function(){ window.open(this.href); return false; }); }); |
To make a link open in a new tab, just add class=”external” to the link.
Example
1 |
<a class="external" href="http://your_url.com/">Link</a> |
New links with that class will now open in a new browser window or tab and be XHTML strict compliant.
Example link