获取网页中的各种长宽、坐标
<!doctype html> <html lang="zh-CN"> <head> <meta charset="UTF-8"> <title>网页中的各种长宽、坐标</title> </head> </head> <body onmousemove="getXandY()"> <label>window.event.clientX:</label><label id="xa" class="xy"></label><br /> <label>window.event.clientY:</label><label id="ya" class="xy"></label><br /> <label>window.event.x :</label><label id="xb" class="xy"></label><br /> <label>window.event.y :</label><label id="yb" class="xy"></label><br /> <label>window.event.screenX:</label><label id="xc" class="xy"></label><br /> <label>window.event.screenY:</label><label id="yc" class="xy"></label><br /><br /> <label>window.screen.height:</label><label id="screenHeight" class="xy"></label><br /> <label>window.screen.width:</label><label id="screenWidth" class="xy"></label><br /><br /> <label>window.document.body.clientHeight:</label><label id="ch" class="xy"></label><br /> <label>window.document.body.clientWidth:</label><label id="cw" class="xy"></label><br /> <label>window.document.body.clientLeft:</label><label id="cl" class="xy"></label><br /> <label>window.document.body.clientTop:</label><label id="ct" class="xy"></label><br /><br /> <label>window.document.body.scrollHeight:</label><label id="sh" class="xy"></label><br /> <label>window.document.body.scrollWidth:</label><label id="sw" class="xy"></label><br /> <label>window.document.body.scrollLeft:</label><label id="sl" class="xy"></label><br /> <label>window.document.body.scrollTop:</label><label id="st" class="xy"></label><br /><br /> <label>window.document.body.offsetHeight:</label><label id="oh" class="xy"></label><br /> <label>window.document.body.offsetWidth:</label><label id="ow" class="xy"></label><br /> <label>window.document.body.offsetLeft:</label><label id="ol" class="xy"></label><br /> <label>window.document.body.offsetTop:</label><label id="ot" class="xy"></label><br /> <script type="text/javascript"> function getXandY(){ var Xa = window.event.clientX; var Ya = window.event.clientY; document.getElementById("xa").innerHTML = Xa; document.getElementById("ya").innerHTML = Ya; var Xb = window.event.x; var Yb = window.event.y; document.getElementById("xb").innerHTML = Xb; document.getElementById("yb").innerHTML = Yb; var Xc = window.event.screenX; var Yc = window.event.screenY; document.getElementById("xc").innerHTML = Xc; document.getElementById("yc").innerHTML = Yc; var screenHeight = window.screen.height; var screenWidth = window.screen.width; document.getElementById("screenHeight").innerHTML = screenHeight; document.getElementById("screenWidth").innerHTML = screenWidth; var clientHeight = window.document.body.clientHeight; var clientWidth = window.document.body.clientWidth; var clientLeft = window.document.body.clientLeft; var clientTop = window.document.body.clientTop; document.getElementById("ch").innerHTML = clientHeight; document.getElementById("cw").innerHTML = clientWidth; document.getElementById("cl").innerHTML = clientLeft; document.getElementById("ct").innerHTML = clientTop; var scrollHeight = window.document.body.scrollHeight; var scrollWidth = window.document.body.scrollWidth; var scrollLeft = window.document.body.scrollLeft; var scrollTop = window.document.body.scrollTop; document.getElementById("sh").innerHTML = scrollHeight; document.getElementById("sw").innerHTML = scrollWidth; document.getElementById("sl").innerHTML = scrollLeft; document.getElementById("st").innerHTML = scrollTop; var offsetHeight = window.document.body.offsetHeight; var offsetWidth = window.document.body.offsetWidth; var offsetLeft = window.document.body.offsetLeft; var offsetTop = window.document.body.offsetTop; document.getElementById("oh").innerHTML = offsetHeight; document.getElementById("ow").innerHTML = offsetWidth; document.getElementById("ol").innerHTML = offsetLeft; document.getElementById("ot").innerHTML = offsetTop; } </script> </body> </html>