如何使用 JavaScript 导航到不同的页面
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8970600/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to navigate to a different page with JavaScript
提问by Krishna N
I'm currently redirecting users to a different page in C# with the following code;
我目前正在使用以下代码将用户重定向到 C# 中的不同页面;
Response.Redirect("somepage.aspx");
However, I'd like to do this in JavaScript instead.
但是,我想在 JavaScript 中执行此操作。
回答by Madhu Beela
Try this code below
试试下面这个代码
<script language="JavaScript">
function move() {
window.location = "http://www.yourdomain.com";
}
</script>
回答by james
Basically you need:
基本上你需要:
function goURL() {
location.href="http://example.com" // change url to your's
}
additional java-script navigation options can be found in following link: http://www.sivamdesign.com/scripts/navigate.html
可以在以下链接中找到其他 java 脚本导航选项:http: //www.sivamdesign.com/scripts/navigate.html