環境: window 10,google 瀏覽器
<html> <!-- 測試肯定框,若是點 "是" ,則返回 true,這樣就觸發 a 標籤的 href 屬性 反之,則什麼也不作,不會觸發 a 標籤的 href 屬性。 --> <head> <title>測試 </title> </head> <body> <a id="button" href="http://www.baidu.com" onclick="fun()"> 點擊跳轉到百度界面 </a> </body> </html> <script> function fun(){ return window.confirm(); } alert(window.confirm("訪問百度嗎?")); </script>
肯定框,若是點 "是" ,則返回 true,這樣就觸發 a 標籤的 href 屬性
反之,則什麼也不作,不會觸發 a 標籤的 href 屬性。html