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

HTML頁面點擊按鈕關(guān)閉頁面的多種方式

  發(fā)布時間:2022-11-22 15:56:19   作者:zhu虎康   我要評論
這篇文章給大家分享HTML頁面點擊按鈕關(guān)閉頁面的幾種方式,實現(xiàn)思路非常簡單,有不帶任何方式的關(guān)閉窗口,提示之后關(guān)閉頁面,點擊關(guān)閉本頁面并跳轉(zhuǎn)到其他頁面等等,每種方式結(jié)合實例代碼給大家介紹的非常詳細(xì),需要的朋友參考下吧

HTML頁面點擊按鈕關(guān)閉頁面的幾種方式

一、不帶任何方式的關(guān)閉窗口

<input type="button" name="close" value="關(guān)閉" onclick="window.close();" />

二、提示之后關(guān)閉頁面

<script>
function custom_close(){
    if(confirm("您確定要關(guān)閉本頁嗎?")){
        window.opener=null;
        window.open('','_self');
        window.close();
    }
    else{
    }
}
</script>
<input id="btnClose" type="button" value="關(guān)閉本頁" onClick="custom_close()" />

三、點擊關(guān)閉本頁面并跳轉(zhuǎn)到其他頁面

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>html中</title>
</head>
<body onbeforeunload="return myFunction()">
<p>該實例演示了如何向 body 元素添加 "onbeforeunload" 事件。</p>
<p>關(guān)閉當(dāng)前窗口,點擊以下鏈接觸發(fā) onbeforeunload 事件。</p>
<a href="http://www.dbjr.com.cn">點擊跳轉(zhuǎn)到腳本之家</a>     
<script>
    function myFunction() {
        return "我在這寫點東西...";
    }
</script>
</body>
</html>

四、將 三 中的方法放到j(luò)s中

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JavaScript 中</title>
</head>
<body>
    <p>該實例演示了如何使用 HTML DOM 向 body 元素添加 "onbeforeunload" 事件。</p>
    <p>關(guān)閉當(dāng)前窗口,按下 F5 或點擊以下鏈接觸發(fā) onbeforeunload 事件。</p>
    <a href="http://www.dbjr.com.cn">點擊調(diào)轉(zhuǎn)到腳本之家</a>
<script>
    window.onbeforeunload = function(event) {
        event.returnValue = "我在這寫點東西...";
    };
</script>
</body>
</html>

到此這篇關(guān)于HTML頁面點擊按鈕關(guān)閉頁面的多種方式的文章就介紹到這了,更多相關(guān)html點擊按鈕關(guān)閉頁面內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持腳本之家!

相關(guān)文章

最新評論