<div>网页可见区域宽:<span id="v1"></span></div> <div>网页可见区域高:<span id="v2"></span></div> <div>屏幕可用工作区宽度:<span id="v3"></span></div> <div>屏幕可用工作区高度:<span id="v4"></span></div> <div>网页可见区域宽:<span id="v5"></span></div> <div>网页可见区域高:<span id="v6"></span></div>
document.getElementById("v1").innerHTML = window.screen.width + "px"; document.getElementById("v2").innerHTML = window.screen.height + "px"; document.getElementById("v3").innerHTML = window.screen.availWidth + "px"; document.getElementById("v4").innerHTML = window.screen.availHeight + "px"; document.getElementById("v5").innerHTML = document.body.offsetWidth + "px"; document.getElementById("v6").innerHTML = document.body.offsetHeight + "px";
文件的文档高度和宽度都设置为100%.
<html style="height: 100%"> <head> <meta charset="UTF-8"> <title>屏幕分辨率宽高测试</title> </head> <body style="height: 100%">
Done!