<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title></title>
</head>
<body>
<span id="show"></span>
<script>
function show() {
var w = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
var h = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
document.getElementById("show").innerHTML=w+" "+h;
}
show();
window.onresize=function(){
show(); //当窗口改变大小时触发事件resize,调用show();
};
</script>
</body>
</html>