欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

JS支付頁(yè)面倒計(jì)時(shí)的實(shí)現(xiàn)示例

 更新時(shí)間:2022年03月31日 09:03:13   作者:dengfengling999  
本文主要介紹了JS支付頁(yè)面倒計(jì)時(shí)的實(shí)現(xiàn)示例,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧

js簡(jiǎn)單實(shí)現(xiàn)支付頁(yè)面跳轉(zhuǎn):

點(diǎn)擊支付,跳出提示框,點(diǎn)擊確定跳轉(zhuǎn)支付成功頁(yè)面二,從10開(kāi)始倒計(jì)時(shí),跳轉(zhuǎn)到主頁(yè)面,主頁(yè)面連接到百度頁(yè)面

頁(yè)面1,代碼如下:

<!DOCTYPE html>
<html lang="en">
 
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
            width: 200px;
            height: 280px;
            background-color: #eee;
            padding: 20px;
            margin: 0 auto
        }
 
        button {
            margin: 30px 25px;
        }
    </style>
</head>
 
<body>
    <div>
        <p>商品:Web前端課程</p>
        <p>原價(jià):1980元</p>
        <p>現(xiàn)價(jià):1.98元</p>
        <p>內(nèi)容:HTML、CSS、JS</p>
        <p>地址:北京市朝陽(yáng)區(qū)</p>
        <p>
            <button>取消</button>
            <button>支付</button>
        </p>
    </div>
    <script>
        //點(diǎn)擊支付按鈕,出現(xiàn)確認(rèn)框
        document.getElementsByTagName('button')[1].onclick = function () {
            let res = window.confirm('您確定要支付嗎?');//顯示提示框
            if (res) {
                location.href = './倒計(jì)時(shí)頁(yè)面2.html';//location對(duì)象下的屬性href
            }
        }
    </script>
 
</body>
 
</html>

點(diǎn)擊支付: 

 點(diǎn)擊確定跳轉(zhuǎn)到倒計(jì)時(shí)頁(yè)面

倒計(jì)時(shí)頁(yè)面,頁(yè)面二,代碼如下:

<!DOCTYPE html>
<html lang="en">
 
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
            margin: 0 auto;
            width: 500px;
        }
 
        #jumpTo {
            color: red;
            font-size: 30px;
        }
    </style>
</head>
 
<body>
    <div>
        <h2>恭喜您,支付成功</h2>
        <span id="jumpTo">10</span>秒后自動(dòng)返回首頁(yè)
        <p><button>立即返回</button></p>
    </div>
    <script>
        //加載頁(yè)面觸發(fā)一個(gè)定時(shí)器 10s
        window.onload = function () {
            let time = 10;//定義一個(gè)變量初始值為10
            setInterval(() => {//創(chuàng)建定時(shí)器
                time--;
                document.getElementById('jumpTo').innerHTML = time;//每隔1秒把time的值減一,賦值給span標(biāo)簽
                if (time == 0) {
                    location.;//當(dāng)時(shí)間為0時(shí)自動(dòng)跳轉(zhuǎn)頁(yè)面
                }
            }, 1000)
        }
        //點(diǎn)擊按鈕立即返回
        document.getElementsByTagName('button')[0].onclick = function () {
            location.;//點(diǎn)擊立即返回,就跳轉(zhuǎn)頁(yè)面
        }
    </script>
</body>
</html>

到此這篇關(guān)于JS支付頁(yè)面倒計(jì)時(shí)的實(shí)現(xiàn)示例的文章就介紹到這了,更多相關(guān)JS支付頁(yè)面倒計(jì)時(shí)內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評(píng)論