[英]Redirect to previous page not working
我已经使用windows.history.back()将用户返回到上一页。 现在此命令不起作用,但是当我放置调试器并进行调试时,页面将重定向到上一页。 但是如果没有在萤火虫中调试的话,它是无法工作的。
我也尝试过windows.go(-1) 。 甚至我在清除缓存后尝试了所有此选项。 仍然无法正常工作,谁能告诉我这是什么问题? 或给我一种使用Java脚本/ J Query或asp.net c#获得浏览器后退按钮功能的替代方法。
只需尝试使用html按钮而不是asp.net按钮或在JavaScript末尾添加return false可能是服务器端单击被调用
您也可以使用C#
编码。
在按钮上单击
if (Request.UrlReferrer != null)
{
Response.Redirect(Request.UrlReferrer.ToString());
}
您正在使用哪个控件将代码编写到上一页。
If you're using Asp:Button
write the javascript code on onclientclick event
window.history.go(-1)
If you're using Html button
write the javascript code on onclick event
window.history.go(-1)
If you're using anchor tag <a>
write the javascript code to href attribute
<a href="javascript:window.history.go(-1);">
尝试这个
onclick="window.history.go(-1)"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.