Learn how to redirect to another webpage using JavaScript.
There are a couple of ways to redirect to another webpage with JavaScript. The most popular ones are location.href
and location.replace
:
// Simulate a mouse click:
window.location.href = "http://www.91xjr.com";
// Simulate an HTTP redirect:
window.location.replace("http://www.91xjr.com");
Try it Yourself »
Note: The difference between href and replace, is that replace()
removes the URL of the current document from the document history, meaning that it is not possible to use the "back" button to navigate back to the original document.
Tip: For more information about the Location Object, read our Location Object Reference.
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!