javascript 警报未触发
我有一个新页面,其中包含以下内容: Response.Redirect 有效,但我事先没有弹出窗口...
有什么想法吗???
protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString["timeout"] != null && Request.QueryString["timeout"].ToString().Equals("yes"))
{
Response.Write("<script>alert('Your Session has Timedout due to Inactivity');</script>");
Response.Redirect("Default.aspx");
}
}
I have a new page with the following:
The Response.Redirect works, but I don't get a popup before hand...
Any ideas???
protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString["timeout"] != null && Request.QueryString["timeout"].ToString().Equals("yes"))
{
Response.Write("<script>alert('Your Session has Timedout due to Inactivity');</script>");
Response.Redirect("Default.aspx");
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Response.Redirect 调用永远不会将代码返回给用户。它立即将用户重定向到下一页。来自 Response.Redirect 上的 MSDN:“任何响应正文内容(例如原始 URL 指示的页面中显示的 HTML 文本或 Response.Write 文本)都将被忽略。”
The Response.Redirect call never returns the code to the user. It immediately redirects the user to the next page. From the MSDN on Response.Redirect: "Any response body content such as displayed HTML text or Response.Write text in the page indicated by the original URL is ignored."
Response.Redirect
会重定向浏览器,并且您的 JavaScript 不会被执行。尝试使用 JavaScript 进行重定向:
The
Response.Redirect
redirects the browser and your JavaScript does not get executed.Try redirecting in JavaScript instead: