時間:2022-12-06來源:www.nowordz.com作者:電腦系統城
HTML頁面點擊按鈕關閉頁面的幾種方式
1 | < input type = "button" name = "close" value = "關閉" onclick = "window.close();" /> |
1 2 3 4 5 6 7 8 9 10 11 12 |
< script > function custom_close(){ if(confirm("您確定要關閉本頁嗎?")){ window.opener=null; window.open('','_self'); window.close(); } else{ } } </ script > < input id = "btnClose" type = "button" value = "關閉本頁" onClick = "custom_close()" /> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
<!DOCTYPE html> < html > < head > < meta charset = "utf-8" > < title >html中</ title > </ head > < body onbeforeunload = "return myFunction()" > < p >該實例演示了如何向 body 元素添加 "onbeforeunload" 事件。</ p > < p >關閉當前窗口,點擊以下鏈接觸發 onbeforeunload 事件。</ p > < a href = "http://www.jb51.net" >點擊跳轉到腳本之家</ a > < script > function myFunction() { return "我在這寫點東西..."; } </ script > </ body > </ html > |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
<!DOCTYPE html> < html > < head > < meta charset = "utf-8" > < title >JavaScript 中</ title > </ head > < body > < p >該實例演示了如何使用 HTML DOM 向 body 元素添加 "onbeforeunload" 事件。</ p > < p >關閉當前窗口,按下 F5 或點擊以下鏈接觸發 onbeforeunload 事件。</ p > < a href = "http://www.jb51.net" >點擊調轉到腳本之家</ a > < script > window.onbeforeunload = function(event) { event.returnValue = "我在這寫點東西..."; }; </ script > </ body > </ html > |
到此這篇關于HTML頁面點擊按鈕關閉頁面的多種方式的文章就介紹到這了
2022-12-06
dw制作虛線圓圈的技巧 html用代碼制作虛線框怎么做?2022-09-12
HTML靜態頁面獲取url參數和UserAgent的實現2022-09-12
html網頁引入svg圖片的4種方式主要介紹了巧用 -webkit-box-reflect 倒影實現各類動效(小結),文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值...
2021-04-22