支付成功后跳转

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title></title>
        <style type="text/css">
            *{
                margin: 0;
                padding: 0;
            }
            #box{
                margin: 100px auto;
                width: 250px;
                height: 200px;
                background-color: darkgray;
                text-align: center;
                line-height: 40px;
            }
        </style>
        <script type="text/javascript">
            /*
                需求
                    点击确认出现弹框,如果点击确定会支付,并且10秒后返回到购买页面
                    点返回则立即返回到购买页面
            */
           window.onload = function(){
             //获取两个按钮
               var buy = document.getElementById("btn01");
               var nobuy = document.getElementById("btn02");
               buy.onclick = function(){
                   var yes = confirm("买吗");
                   if(yes){
                       // window.open("成功后界面.html","_self");
                       window.location.href = "成功后界面.html";
                   }else{
                       alert("您取消了支付~~");
                   }
               }
               nobuy.onclick = function(){
                   alert("不买就不要点我~~");
               }
           };
        </script>
    </head>
    <body>
        <div id="box">
            <p>商品:Wbe前端课程</p>
            <p>原件:1980</p>
            <p>现价:1.98</p>
            <p>内容:HTML、CSS、JS</p>
            <p>地址:中国</p>
            <button id="btn01">购买</button>
            <button id="btn02">不买,太贵了</button>
        </div>
    </body>
</html>

 

posted @ 2022-02-25 17:01  st-159  阅读(136)  评论(0)    收藏  举报