基于JS实现01支付后的10秒倒计时

《基于JS实现01支付后的10秒倒计时》这是一个通过js实现的支付后的页面,点击支付会跳出一个弹窗,提示你是否要确定支付,确定后进入付后界面,该页面有着10秒倒计时,计时结束后便会返回原界面,也可以选…

  1. 这是一个通过js实现的支付后的页面,点击支付会跳出一个弹窗,提示你是否要确定支付,确定后进入付后界面,该页面有着10秒倒计时,计时结束后便会返回原界面。也可以选择立刻返回,来返回主页面<br>第一个zhifu.html页面<br><!DOCTYPE html>
  2. <html lang=“en”>
  3. <head>
  4.      <meta charset=“UTF-8”>
  5.      <meta httpequiv=“X-UA-Compatible” content=“IE=edge”>
  6.      <meta name=“viewport” content=“width=device-width, initial-scale=1.0”>
  7.      <title>支付页面</title>
  8.      <style>
  9.          div {
  10.              width: 200px;
  11.              height: 280px;
  12.              backgroundcolor: #eee;
  13.              padding: 20px;
  14.              margin: auto;
  15.          }
  16.          button {
  17.              margin: 30px 25px;
  18.          }
  19.      </style>
  20. </head>
  21. <body>
  22.      <div>
  23.          <p>商品:web前端课程</p>
  24.          <p>原价:1980元</p>
  25.          <p>现价:1.98元</p>
  26.          <p>内容:htmlcssJavaScript</p>
  27.          <p>地址:郑州升达经贸管理学院</p>
  28.          <p>
  29.              <button>取消</button>
  30.              <button>支付</button>
  31.          </p>
  32.      </div>
  33.      <script>
  34.          //点击支付出现确认框
  35.          document.getElementsByTagName(‘button’)[1].onclick = function() {
  36.              let res = window.confirm(‘您确认要支付吗?’)
  37.              if (res) {
  38.                  location.href = ‘./ten.html’
  39.              }
  40.          }
  41.      </script>
  42. </body>
  43. </html><br>第二个ten.html页面<!DOCTYPE html>
  44. <html lang=“en”>
  45. <head>
  46.      <meta charset=“UTF-8”>
  47.      <meta httpequiv=“X-UA-Compatible” content=“IE=edge”>
  48.      <meta name=“viewport” content=“width=device-width, initial-scale=1.0”>
  49.      <title>10秒倒计时</title>
  50.      <style>
  51.          div {
  52.              margin: 0 auto;
  53.              width: 500px;
  54.          }
  55.          #jumpto {
  56.              color: red;
  57.              fontsize: 30px;
  58.          }
  59.      </style>
  60. </head>
  61. <body>
  62.      <div>
  63.          <h2>恭喜您,支付成功</h2>
  64.          <span id=“jumpto”>10</span>秒后自动返回首页
  65.          <p><button>立刻返回</button></p>
  66.      </div>
  67.      <script>
  68.          //加载页面时,应该触发定时器时间10s
  69.          window.onload = function() {
  70.              let timer = 10;
  71.              setInterval(() => {
  72.                  timer–;
  73.                  document.getElementById(‘jumpto’).innerHTML = timer;
  74.                  if (timer == 0) {
  75.                      location.href = ‘./zhifu.html’;
  76.                  }
  77.              }, 1000);
  78.          }
  79.          document.getElementsByTagName(‘button’)[0].onclick = function() {
  80.              location.href = ‘./zhifu.html’;
  81.          }
  82.      </script>
  83. </body>
  84. </html>

-1

-2

到此这篇关于基于JS实现01支付后的10秒倒计时的文章就介绍到这了,更多相关js 10秒倒计时内容请搜索我们以前的文章或继续浏览下面的相关文章希望大家以后多多支持我们!

标签

发表评论