支付成功后跳转
<!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>
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构