编写相应程序代码即可。
代码如下:
<script>
function getInfo()
{
var s = ""
s += " 网页可见区域宽:"+ document.body.clientWidth
s += " 网页可见区域高:"+ document.body.clientHeight
s += " 网页可见区域宽:"+ document.body.offsetWidth + " (包括边线和滚动条的宽)"
s += " 网页可见区域高:"+ document.body.offsetHeight + " (包括边线的宽)"
s += " 网页正文全文宽:"+ document.body.scrollWidth
s += " 网页正文全文高:"+ document.body.scrollHeight
s += " 网页被卷去的高(ff):"+ document.body.scrollTop
s += " 网页被卷去的高(ie):"+ document.documentElement.scrollTop
s += " 网页被卷去的左:"+ document.body.scrollLeft
s += " 网页正文部分上:"+ window.screenTop
s += " 网页正文部分左:"+ window.screenLeft
s += " 屏幕分辨率的高:"+ window.screen.height s += " 屏幕分辨率的宽:"+ window.screen.width
s += " 屏幕可用工作区高度:"+ window.screen.availHeight
s += " 屏幕可用工作区宽度:"+ window.screen.availWidth
s += " 你的屏幕设置是 "+ window.screen.colorDepth +" 位彩色"
s += " 你的屏幕设置 "+ window.screen.deviceXDPI +" 像素/英寸"
//alert (s)
}
getInfo()
</script>
<!DOCTYPE html><html lang="en">
<head>
<meta charset="UTF-8">
<title>test</title>
<style>
#div {
width: 100px
height: 50px
border: 1px solid red
color: green
text-align: center
}
input {
width: 250px
}
</style>
<script>
function test() {
var a = document.getElementById('a')
var b = document.getElementById('b')
var div = document.getElementById('div')
div.style.width = a.value + 'px'
div.style.height = b.value + 'px'
}
</script>
</head>
<body>
<div>宽度(默认100px):<input type="text" id="a" placeholder="输入想要的宽度,点击测试看效果" /></div>
<div>高度(默认50px):<input type="text" id="b" placeholder="输入想要的高度,点击测试看效果" /></div>
<div><button onclick="test()">点击测试</button></div>
<div id="div">来改变我</div>
</body>
</html>