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
- 课程推荐
- 课件下载
课件暂不提供下载,工作人员正在整理中,后期请多关注该课程~ 















