window history back (-1) not working

为君一笑 提交于 2019-12-20 04:59:06

问题


I have use below code to back for the previous page, but it's not working. the alert box still popup even i click ok on the page. actually there have 3 page include this windows page code. 1st page is user need to fill up the form is name redeem_newcust.asp and the action should be save all the data into the database named redeem_newcustDB.asp. In page redeem_newcustDB.asp have one code to select option for type of redemption then this page will point action to the page redeem_newprocess.asp with is included as below code. Means when user click on type of redemption not equal to "Birthday Pack - PDV RM50" then it should be back to the previous page that means page redeem_newcustDB.asp. It's possible to having back to that previous page..? Should b need to bring all the value? Please help, thanks

If redeemtype = "Birthday Pack - PDV RM50" then
        Response.Redirect("redeem_newbirth.asp?cardno="&BlinkCard&"&redeemtype="&redeemtype&"")
    Else
        %>
            <script language="javascript">
            <!--
            window.alert ("Please choose Type of Redemption");
            window.history.go(-1);
            //-->
            </script>
        <%   
End If

%>

回答1:


Use: window.history.back() instead .go();

http://www.w3schools.com/jsref/met_his_back.asp

or use:

window.alert("Please choose Type of Redemption");
setTimeout(function(){
  window.history.go(-1);
},500);



回答2:


I would always avoid using alert(), since it kills script in some Browsers. I would open() a new window and ButtonElement.onclick use location =.

Note:

window is implicit, so you don't need to write window.open() or window.location. Additionally, it's fine to leave off .href when referring to location.href



来源:https://stackoverflow.com/questions/20694754/window-history-back-1-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!