通過提示框跳轉頁面 1 <!doctype html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <title>Document</title> 6 </head> 7 <body> 8 <script> 9 window.onlo
通過提示框跳轉頁面
1 <!doctype html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <title>Document</title> 6 </head> 7 <body> 8 <script> 9 window.onload = function(){ //設置當頁面載入時執行 10 var btn =document.getElementsByTagName("button")[0] //獲取btn元素 11 btn.onclick = function(){ //給button加上一個點擊事件 12 var answer = confirm("是否想游覽ziksang博客園") //把確認框賦值給answer 13 if(answer) //判斷是否點擊確定 14 window.location ="http://www.cnblogs.com/Ziksang/" //確定的話游覽器自身跳轉 15 } 16 17 } 18 </script> 19 <button>點擊跳轉</button> 20 </body> 21 </html>