Aspdotnet-Suresh

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

jQuery Redirect to Another Page with Button Click in JavaScript

Jun 12, 2013
Introduction

Here I will explain simple jQuery code to redirect user to another web page using jQuery and JavaScript. By using location object in jQuery or JavaScript we can redirect user to another web page.  

Description:


Redirect User to Another web page using jQuery

To redirect user to another web page in jQuery we need to write the code like as shown below


var url = 'http://www.aspdotnet-suresh.com';
$(location).attr('href', url);
Example


<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
</head>
<body>
<input type="button" id="btnclick" value="Redirect" />
<script type="text/javascript">
$(function() {
$("#btnclick").click(function() {
var url = 'http://www.aspdotnet-suresh.com';
$(location).attr('href', url);
})
});
</script>
</body>
</html>
Redirect User to Another web page in jQuery

To redirect user to another web page in JavaScript we need to write the code like as shown below


var url = 'http://www.aspdotnet-suresh.com';
window.location.href = url;
Or


var url = 'http://www.aspdotnet-suresh.com';
window.location = url;
Example


<html>
<head>
</head>
<body>
<input type="button" id="btnclick" value="Redirect" onclick="RedirectSample()" />
<script type="text/javascript">
function RedirectSample() {
var url = 'http://www.aspdotnet-suresh.com';
window.location.href = url;
}
</script>
</body>
</html>

In this way we can redirect user to another web page using jQuery or JavaScript

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.

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

11 comments :

Anonymous said...

Sir , This is abhinavsingh993 It is a great article

nandhakumar said...

Great Article

Anonymous said...

very good article.

Rashid A said...

thanks

Rashid A said...

sir i want to apply tagging for images in asp.net.Please help me sir

Anonymous said...

testing

Anonymous said...

Sir, This Abhinavsingh993 very good article sir.

Karthick said...

Hi suresh,
Here what is difference between window.location.href = url; and
window.location = url; and
var url = 'http://www.aspdotnet-suresh.com';
$(location).attr('href', url);

Amit Singh said...

Thanks Suresh u make me understand ASP.NET.
u r my Tutor. i think u'll help me in future to solve my problem. once again heartfull thanks

Amit Kr Singh

Ketul Parmar said...

Nice tips you share. It is very useful.

Anonymous said...

dfghgjk

Give your Valuable Comments

Other Related Posts

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