aspdotnet-suresh offers articles and tutorials,csharp dot net, articles and tutorials,VB.NET Articles,Gridview articles,code examples of 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

jQuery Open All External Links in New Window

Aug 24, 2012

Here I will explain how to use jQuery to open all external links in new window or open all external links in new window using jQuery

In previous article I explained
open all hyperlinks in new window, expand textbox on focus and disable right click on image using JQuery and many articles relating to JQuery. Now I will explain how to open external links in new window using JQuery in

Previous post open all hyperlinks in new window will open all internal and external links in new window. In many situations everybody prefer to open their website internal links in same window and external links (other website links) should be open in new window

To implement this concept we need to write code as shown below

<html xmlns="">
<head id="Head1" runat="server">
<title>JQuery open all hyperlinks in new window</title>
<script type="text/javascript" src="">
<script type="text/javascript">
$(document).ready(function() {
$("a[href^='http:']:not([href*='" + + "'])").click(function() {$(this).prop('href'), '', 'height=600,width=700');
return false
<a href="">Aspdotnet-Suresh</a><br />
<a href="">Google</a><br />
<a href="">Bing</a><br />
If you observe above code in header section I wrote code to open external links in new window and internal links in same window.


If you want to check demo click on Aspdotnet-Suresh link it will open in same window and click on google or bing links it will open in new windows 

If you enjoyed this post, please support the blog below. It's FREE!

Get the latest,, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email


Give your Valuable Comments

Other Related Posts

© 2015 All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.