简体   繁体   English

重定向到上一页不起作用

[英]Redirect to previous page not working

i have used windows.history.back() to return user to previous page. 我已经使用windows.history.back()将用户返回到上一页。 now this command is not working but when i put debugger and do debug then page is getting redirect to previous page. 现在此命令不起作用,但是当我放置调试器并进行调试时,页面将重定向到上一页。 but without debugging in firebug it is not working . 但是如果没有在萤火虫中调试的话,它是无法工作的。
i have also tried windows.go(-1) . 我也尝试过windows.go(-1) and even i tried all this option after clearing cache. 甚至我在清除缓存后尝试了所有此选项。 still not working can anyone tell me what is problem? 仍然无法正常工作,谁能告诉我这是什么问题? or give me alternative way to get browser back button functionality using java script/J Query or asp.net c#. 或给我一种使用Java脚本/ J Query或asp.net c#获得浏览器后退按钮功能的替代方法。

只需尝试使用html按钮而不是asp.net按钮或在JavaScript末尾添加return false可能是服务器端单击被调用

You can use C# Coding also for it. 您也可以使用C#编码。

On Button click 在按钮上单击

if (Request.UrlReferrer != null)
{
Response.Redirect(Request.UrlReferrer.ToString()); 
}

Which control are you using to write code to previous page. 您正在使用哪个控件将代码编写到上一页。

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM