Subscribe For Free Updates!

We'll not spam mate! We promise.

Aug 27, 2012

ASP.Net Tutorials:Open External Link in New Window Using JQuery

Views:

Open all Link in New Window Using JQuery in Asp.net
To day I will explain you how to open all external links in new window using JQuery in asp.net.

In Prevision Article i explained you how to Show Alert Box Through JQuery in Asp.net when user is idle or inactive.


If we don't open the external links on our website in a New Window, we can loose all our visitor or viewers. So It is important always to open All External link in New Window or Tab as for most websites views are everything.




So  Lets Start!! Firstly Create a Project in Asp.Net in Visual Studio.
and Write the Following Code.
<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">
$undefineddocument).readyundefinedfunctionundefined) {
$undefined"a[href^='http:']:notundefined[href*='" + window.location.host + "'])").clickundefinedfunctionundefined) {
window.openundefined$undefinedthis).propundefined'href'), '', 'height=600,width=700');
return false
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<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>
</form>
</body>
</html>

 If you observe the above code, in the header section I have written code in jquery to exclusively open external links in a new window and internal links in the same window.

Sample Out Put


Open all Link in New Window Using JQuery in Asp.net

DOWNLOAD Source Code

Plese Feel Free to Socializer This Post
SOCIALIZE IT →
FOLLOW US →
SHARE IT →

0 comments:

Post a Comment

Become a Fan

visual studio learn