I have used the Webpage redirection with PHP. But I want to do it with Javascript or jQuery if it is possible. I want to redirect the user to another page when he clicks on a button or something like this.
Asked
Active
Viewed 64 times
-1
-
possible duplicate of [How can I make a redirect page in jQuery/JavaScript?](http://stackoverflow.com/questions/503093/how-can-i-make-a-redirect-page-in-jquery-javascript) – Amit Joki Jul 30 '14 at 16:24
-
Why are you preferring one over the other? Give us some context so that we might be able to suggest some alternatives for you. – esqew Jul 30 '14 at 16:24
-
This question shows no research effort. – j08691 Jul 30 '14 at 16:25
-
Amazingly, a Google search for "JavaScript redirect" yields a lot of useful information. – David Jul 30 '14 at 16:25
2 Answers
2
You can use the attr() method of jQuery to redirect a web page:
var url = "http://google.com";
$(location).attr('href',url);

Ali Hossain
- 21
- 3
1
There are several methods for javascript redirection. You can use any of these methods:
window.location.href = ”submit.php”;
or
window.location.replace("http://google.com");
or
window.location.assign("http://bing.com");
I would suggest location.href for that.
You can also have a look at this helpful Javascript redirect tutorial.

Sadi
- 366
- 3
- 6