offsetX, offsetY是鼠標當前相對於網頁中的某一區域的位置,當鼠標位於頁面中這一區域的左上角時offsetX=0, offsetY=0;
screenX, screenY是相對於用戶顯示器的位置
x,y是鼠標相對於當前瀏覽器的位置
<HEAD><TITLE>Measure for Measure</TITLE>
<SCRIPT>
<!--
function one() {
report.value = "The DIV above is relatively positioned in the BODY. The style object contains the information that was set in the inline style to position this object. The following are the values that would be reported for the various position and dimension properties on the style object for the DIV:" + "/n/n";
report.value= report.value + " mydiv.style.top (string) = " + foodiv.style.top + "/n";
report.value= report.value + " mydiv.style.left (string) = " + foodiv.style.left + "/n";
report.value= report.value + " mydiv.style.height (string) = " + foodiv.style.height + "/n";
report.value= report.value + " mydiv.style.width (string) = " + foodiv.style.width + "/n";
report.value= report.value + " mydiv.style.pixelTop (long) = " + foodiv.style.pixelTop + "/n";
report.value= report.value + " mydiv.style.pixelLeft (long) = " + foodiv.style.pixelLeft + "/n";
report.value= report.value + " mydiv.style.pixelHeight (long) = " + foodiv.style.pixelHeight + "/n";
report.value= report.value + " mydiv.style.pixelWidth (long) = " + foodiv.style.pixelWidth + "/n";
report.value= report.value + " mydiv.style.posTop (long) = " + foodiv.style.posTop + "/n";
report.value= report.value + " mydiv.style.posLeft (long) = " + foodiv.style.posLeft + "/n";
report.value= report.value + " mydiv.style.posHeight (long) = " + foodiv.style.posHeight + "/n";
report.value= report.value + " mydiv.style.posWidth (long) = " + foodiv.style.posWidth + "/n";
}
function two() {
report.value = "Each object has a set of offset positions. The offset properties for the positioned darkBlue DIV above are: /n";
report.value= report.value + " offsetLeft = " + foodiv.offsetLeft + "/n";
report.value= report.value + " offsetTop = " + foodiv.offsetTop + "/n";
report.value= report.value + " offsetHeight = " + foodiv.offsetHeight + "/n";
report.value= report.value + " offsetWidth = " + foodiv.offsetWidth + "/n";
report.value= report.value + " offsetLeft = " + document.body.offsetLeft + "/n";
report.value= report.value + " offsetTop = " + document.body.offsetTop + "/n";
report.value= report.value + " offsetHeight = " + document.body.offsetHeight + "/n";
report.value= report.value + " offsetWidth = " + document.body.offsetWidth + "/n";
}
function three() {
report.value = "Scroll values for the darkBlue DIV object" + "/n";
report.value= report