Asked by Lucky13
You can use the following code to go to another page:
window.location = "http://www.yoururl.com";
Answered by seedg
It’s preferable to window.location. href=”http://sidanmor.com”>href=”http://sidanmor.com”>href=”http://sidanmor.com
Replace() is preferable since it removes the initial page from the session history, preventing the user from becoming trapped in a never-ending back-button saga.
// similar behavior as an HTTP redirect window.location.replace("http://sidanmor.com"); // similar behavior as clicking on a link window.location.href = "http://sidanmor.com";
Taken from this website: How to use jQuery to redirect to another page.
Answered by sidanmor
A function can’t be redirected to. When redirecting, you can pass a flag on the URL, check that flag in the server side code, and if it’s raised, call the function.
document.location = "MyPage.php?action=DoThis";
Then, in your PHP code, look for the word “action” in the query string and, if it’s equal to “DoThis,” call whatever function you want.
Answered by Shadow Wizard Hates Omicron
// Similar behavior as an HTTP redirect window.location.replace("http://stackoverflow.com"); // Similar behavior as clicking on a link window.location.href = "http://stackoverflow.com";
This information was copied from a duplicate question’s response.
Answered by 5 revs, 2 users 86%
It’s possible that you’ll need to expand on your question.
When you say “redirect,” most people think of changing the HTML page’s location:
window.location = url;
It’s not clear what you mean when you say “redirect to function.” You have the option of calling a function or redirecting to another website. You may even redirect to a new page and have a function run when it loads.
Answered by Fenton