jQuery redirect the user from one page to another

jQuery redirect the user from one page to another

Today, We want to share with you jQuery redirect the user from one page to another.
In this post we will show you jQuery redirect the user from one page to another, hear for jQuery redirect the user from one page to another we will give you demo and example for implement.
In this post, we will learn about jQuery Redirect to Another Page on Button Click with an example.

“Simple Use the JavaScript window.location Property”

-jQuery is not a programming language but as a well written simple JavaScript code used in libs.
-jQuery is a simple JavaScript code, which do document(DOM) traversing, event handling and genrate events, Ajax interactions scope and Animations.
-jQuery is a very fast, lightweight data, feature-rich content to client side JavaScript framework.

JQuery Code to redirect a page or URL.

Redirecting a web page simple means, taking user to send new location.Other Means “SendRedirect and Forward Methods”

 var url = "https://www.pakainfo.com";
$(location).attr('href',url);

Redirect to another page in JavaScript-Example

jQuery redirection and response to return http response simple status code success: 200 OK.

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="utf-8">
    <title>Redirect to another page in JavaScript - pakainfo.com</title>
    <script type="text/javascript">
        function pageRedirect() {
            window.location.replace("https://www.pakainfo.com");
        }      
        setTimeout("pageRedirect()", 1000);
    </script>
    </head>
    <body>
        <p></p>
    </body>
    </html>

JavaScript – For example:

jQuery is not required, and simple used to window.location.replace(…) will best solution on simulate an HTTP page redirect.

//  HTTP redirect
window.location.replace("https://www.pakainfo.com");

//  clicking on a link
window.location.href = "https://www.pakainfo.com";

index.html

<input type="button" id="redirect" value="click to redirect" />

The JQuery code : 3- Examples

1. Using window.location.replace

$(document).ready(function () {
    $("#redirect").click(function () {
    window.location.replace("https://www.pakainfo.com"); //page will redirect to pakainfo.com   
 })

2. Using window.location.href

$(document).ready(function () {
      $("#redirect").click(function () {
          window.location.href ="https://www.pakainfo.com";
		  //page will redirect to pakainfo.com 
      })
})

3. Using $(location).attr

 $(document).ready(function () {
        $("#redirect").click(function () {
           var url = "https://www.pakainfo.com"
           $(location).attr('href', url);
		   //page will redirect to pakainfo.com 
         })          
  })

View Demo

We hope you get an idea about jQuery redirect the user from one page to another
We would like to have feedback on my Information blog .
Your valuable any feedback, Good question, Inspirational Quotes, or Motivational comments about this article are always welcome.
If you liked this post, Please don’t forget to share this as Well as Like FaceBook Page.

We hope This Post can help you…….Good Luck!.


Related FAQ

Here are some more FAQ related to this Article:

  1.   PHP Ajax Form Validation without page refresh
  2.   PHP Autocomplete search with typeahead.js
  3.   jQuery Trigger Custom Events Example
  4.   JavaScript Redirect URL Example
  5.   jQuery Get the Text Value of Selected Option
  6.   JavaScript Automatically Page Redirection
  7.   Laravel Datatables Individual column searching using Ajax Jquery
  8.   JQUERY Examples Programming Tutorials
  9.   Apache Virtual Host Tutorials - Setup Apache Virtual Hosts with Ubuntu
  10.   Ajax Image Upload without Refreshing Page using Jquery