JS中 confirm() 方法


前言

環境: 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 屬性。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM