使用JavaScript函数从ASP.NET页面重定向到另一个页面

12

我知道如果我想在ASP.NET页面的代码后端从一个页面重定向到另一个页面,我需要编写以下代码 -

Response.Redirect("SomePage.aspx");

我的问题是是否可能在JavaScript函数中执行同样的操作,如果可能,该如何实现?

谢谢!


4
你有做过任何研究吗? - Steve
可能是重复的问题:使用JavaScript跳转到新的HTML页面 - NoWar
http://stackoverflow.com/questions/17874481/redirecting-to-an-aspx-page-using-javascript - Jay
3个回答

30
这应该可以做到:
window.location = "SomePage.aspx";
或者
window.location.href="SomePage.aspx";
或者
window.location.assign("SomePage.aspx");

这是一篇旧帖子,但您如何在此基础上添加一个5秒的计时器? - BarclayVision

1
尝试这个...
ScriptManager.RegisterStartupScript(this, this.GetType(), "onclick", "javascript:window.open( 'SomePage.aspx','_blank','height=600px,width=600px,scrollbars=1');", true);

0
你可以尝试这个。
window.location.href = 'page.aspx';

我不知道这是否是最好的方法


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接