Introduction:
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
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
Description:
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 asp.net.
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 asp.net.
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="http://www.w3.org/1999/xhtml">
<head id="Head1"
runat="server">
<title>JQuery open all hyperlinks in new window</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js">
</script>
<script type="text/javascript">
$(document).ready(function()
{
$("a[href^='http:']:not([href*='"
+ window.location.host + "'])").click(function() {
window.open($(this).prop('href'), '', 'height=600,width=700');
return false
});
});
</script>
</head>
<body>
<div>
<a href="http://www.aspdotnet-suresh.com/search/label/Asp.net">Aspdotnet-Suresh</a><br />
<a href="http://www.google.com">Google</a><br />
<a href="http://www.bing.com">Bing</a><br />
</div>
</body>
</html>
|
If
you observe above code in header section I wrote code to open external links in
new window and internal links in same window.
Demo
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 Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email. |
|||
|
|||
0 comments :
Note: Only a member of this blog may post a comment.