window對象
JavaScript可以取得瀏覽器提供的許多對象,並進行操作。
window
window物件不但充當全域作用域,而且表示瀏覽器視窗。
window物件有innerWidth和innerHeight屬性,可以取得瀏覽器視窗的內部寬度和高度。內部寬高是指除去功能表列、工具列、邊框等佔位元素後,用於顯示網頁的淨寬高。
相容性:IE<=8不支援。
<html>
<head>
<script>
'use strict';
alert('window inner size: ' + window.innerWidth + ' x ' + window.innerHeight);
</script>
</head>
<body>
</body>
</html>對應的,還有一個outerWidth和outerHeight屬性,可以取得瀏覽器視窗的整個寬高。
新建檔案
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>window对象</title>
<script type="text/javascript">
function myFunction()
{
alert("欢迎来到phpd中文网")
window.open('//m.sbmmt.com','_blank','width=600 height=400')
}
</script>
</head>
<body>
<form>
<input type="button" value="点击我,打开新窗口" onclick="myFunction()" />
</form>
</body>
預覽
Clear
- 課程推薦
- 課件下載
課件暫不提供下載,工作人員正在整理中,後期請多關注該課程~ 















