1. 程式人生 > >javascript,window物件,window物件案例,window物件的使用

javascript,window物件,window物件案例,window物件的使用

javascript,window物件,window物件案例,window物件的使用

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>javascript,window物件,window物件案例,window物件的使用,雪豹軟體工作室</title>
<script type="text/javascript">
	//window.confirm("請確定刪除嗎?");
	//alert(window.screen.availWidth + " " + screen.availHeight);
	//alert("sss");
	//window.open("http://www.baidu.com", "我的百度", "", false);
	//var myName = "jack";
	//alert(window.myName);
	//window.prompt("hello", "world");
	
	function closeDemo(){
		//alert("關閉當前頁面!");
		//close();
		//window.open(' ','_self');
		//window.close(); 
		//window.open("about:blank","_self").close();
		//window.open("","_self").close();
		//window.open("about:blank","_self");
		//window.close();
		//open(' ', '_self').close();
		
	/* var userAgent = navigator.userAgent;
		alert(userAgent);
		//return false;
		if (userAgent.indexOf("Firefox") != -1
				|| userAgent.indexOf("Chrome") != -1) {
			window.location.href = "about:blank";
		} else {
			window.opener = null;
			window.open("", "_self");
			window.close();
		} */
		//window.open('', 'test').close();
		/* setTimeout(function(){
		    window.open(' ', '_self', '');
		    window.close();
		}, 100); */
	//	var number = Math.random();
	//	console.log(number);
	//	window.open ("http://www.baidu.com", "myWiddown" + number);
	
	//經測試,close()函式,在IE瀏覽器,火狐瀏覽器中都可以正常關閉視窗,暫不支援谷歌瀏覽器(測試時間:2017-08-24)
	
		/* if (window.confirm("您確定要關閉視窗嗎?")) {
			window.close();
		} */
		window.close();
	}
	function showModalDialogDemo() {
		
		//window.showModalDialog()函式,只支援IE瀏覽器和火狐瀏覽器,不支援谷歌瀏覽器(測試時間:2017-08-24)
		//window.showModalDialog("calculator.html");
		//showModelessDialog()函式只支援IE瀏覽器,不支援谷歌瀏覽器和火狐瀏覽器(測試時間:2017-08-24)
		window.showModelessDialog("calculator.html");
		status = "hello";
	}
</script>
</head>
<body>
<input type="button" value="close" onclick="closeDemo()"><br><br>
<input type="button" value="showModalDialog" onclick="showModalDialogDemo()"><br><br>
<h3><font color="red">測試超連結的target屬性(target="_top"和target="_parent"沒有具體去深究,有時間再研究_parent和_top這2個值)</font></h3>
<h4><font color="blue">超連結a的target屬性知識,可參考如下網址</font></h4>
<a href="https://wenku.baidu.com/view/cf0b0f49ac02de80d4d8d15abe23482fb4da020a.html" target="test1">
https://wenku.baidu.com/view/cf0b0f49ac02de80d4d8d15abe23482fb4da020a.html
</a><br><br>
<a href="http://www.cnblogs.com/starof/p/4014691.html" target="test2">
http://www.cnblogs.com/starof/p/4014691.html
</a><br><br>
<hr>
<a href="calculator.html" target="helloWorld">計算器頁面連結</a><br><br>
<a href="http://www.soso.com" target="helloWorld">soso頁面連結</a><br><br>
<a href="http://cn.bing.com" target="helloWorld">微軟必應</a><br><br>
<a href="http://cn.bing.com" target="_self">測試_self</a><br><br>
<a href="http://cn.bing.com" target="_blank">測試_blank</a><br><br>
<a href="http://cn.bing.com" target="_new">測試_new</a><br><br>
<a href="http://cn.bing.com">預設target屬性為_self</a><br><br>
<a href="http://cn.bing.com" target="_top">測試_top</a><br><br>
<a href="http://cn.bing.com" target="_parent">測試_parent</a><br><br>
</body>
</html>