How can I redirect the user from one page to another using jQuery?
I saw both window.location = url; and window.location.href = url; How are they different?
Make a redirect page in jQuery /JavaScript
-
- Posts:107
Make a redirect page in jQuery /JavaScript
Admin
Posts:805
window.location returns an object.
jQuery is not necessary, and window.location.replace(...) will best simulate an HTTP redirect.
It is better than using window.location.href = '...';, because replace() does not put the originating page in the session history, meaning the user won't get stuck in a never-ending back-button fiasco.
- If you want to simulate someone clicking on a link, use: location.href.
- If you want to simulate an HTTP redirect, use: location.replace().
For example:
jQuery is not necessary, and window.location.replace(...) will best simulate an HTTP redirect.
It is better than using window.location.href = '...';, because replace() does not put the originating page in the session history, meaning the user won't get stuck in a never-ending back-button fiasco.
- If you want to simulate someone clicking on a link, use: location.href.
- If you want to simulate an HTTP redirect, use: location.replace().
For example:
Code: Select all
// similar behavior as an HTTP redirect
window.location.replace('https://coursesweb.net');
// similar behavior as clicking on a link
window.location.href = 'https://coursesweb.net';
joviermark
Posts:1
Check this tutorial about Javascript Redirect. address:
corelangs.com/js/basics/redirect.html
corelangs.com/js/basics/redirect.html
Root13
Posts:9
I think, it's better to use replace()
Similar Topics
- Redirect according to browser type
JavaScript - jQuery - Ajax First post
Pleasant Coursesweb,Last post
I have two `simple` javascript what I wanna combine between detecting in two different browsers to script to another page....
Marplo thanks for quick feedback took me more hours, I should have come earlier with asking questions.
It is a waste I`m not have experiance with... - Hour and Minutes togheter in Javascript
JavaScript - jQuery - Ajax First post
Dear Coursesweb I can not find out how to add the hours + minutes togheter.Last post
<SCRIPT LANGUAGE= JavaScript >
day = new Date()
hr =...
See and use the following example:
<script>
var day = new Date();
let hr = day.getHours();
let mn = day.getMinutes();
let se =... - Display message to every minute in Javascript
JavaScript - jQuery - Ajax First post
Hello,Last post
On eatch minute from the current hour I wanna have an message
I can not find out how to complete
I hope to get something like this (code...
If you only want to display a message to every minute, just use the setInterval() function. It calls a function repeatedly, over and over again, at...