window history back (-1) not working

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

%>

Answers:

Answer

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);
Answer

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

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.