Grab the RSS feed

Page Redirection Using Jquery

Sometimes we need to redirect the page from the current page to another page.For example if the login is successful the we need to redirect into the Myprofile page or another page wherever you want.

This is simple in Jquery.

Like the javascript window.location.href here also we have the function to redirect.

In the below example I illustrate the page redirection with simple button.If you want to make it depend upon user input in textbox there is also a code.For that you can simply remove the comment lines and use it.

The code is given below

< !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
< xmlns="http://www.w3.org/1999/xhtml">
<>
< equiv="Content-Type" content="text/html; charset=utf-8">
<>
< src="jquery/jquery.js" type="text/javascript">< /script >
<>
$(document).ready(function(){
$("#pageredirect").click(function()
{
/*Remove the comment line and put the comment line in var url="http://www.technotiger87.blogspot.com";*/
/*It will redirect to the particular page given by user in text box*/
//var url=$("#testing").val();

var url = "http://www.technotiger87.blogspot.com"; 
$(location).attr('href',url);

});
});
< /script >
< /head >
<>
< !--Remove the below comment line when you want to enter the URL and redirect it-- >
< !--Redirect Url:< type="text" name="testing" id="testing">
< type="button" name="pageredirect" id="pageredirect" value="Redirect">
< /body >
< /html >

click here to download at pdf format

Leave the comments…

0 comments:

  •  
    Real Time Web Analytics