offsetLeft 属性: Retrieves the calculated left position of the object relative to the layout or coordinate parent。 说明: You can determine the location, width, and height of an object by using a combination of the offsetLeft, offsetTop, offsetHeight, and offsetWidth properties. These numeric properties specify the physical coordinates and dimensions of the object relative to the object's offset parent. ClientLeft属性: Retrieves the distance between the offsetLeft property and the true left side of the client area. 区别: The difference between the offsetLeft and clientLeft properties is the border of the object.
例子: <SCRIPT> function isinView(oObject) { var oParent = oObject.offsetParent; var iOffsetLeft = oDiv.offsetLeft; var iClientWidth = oParent.clientWidth; if (iOffsetLeft > iClientWidth) { alert("Scroll right for the message."); } } </SCRIPT> : <BUTTON onclick="isinView(this)">Click here</BUTTON> : <DIV ID=oDiv STYLE="position:absolute; top:200; left:1200;"> : </DIV>
function messageTable() {
alert("tableid: (" + tableid.offsetLeft + "," + tableid.offsetLeft + ")");
}
function messageMouse() {
alert("mouse: (" + window.event.x + "," + window.event.y + ")");
}
</script>
<body ondblclick="messageMouse()">
<br><br>
<table width="750">
<tr>
<td>
</td>
<td>
<table id="tableid" name="tableid" style="position:relative; background-color:#aaaaaa">
<tr>
<td>
This is a table. It's id is "tableid"
</td>
</tr>
</table>
</td>
</tr>
</table>
<br>
<input type="button" value="show table(x, y)"onclick="messageTable()">
<br>
Double click to show mouse(x, y)
</body>
可以去查pws的技术支持(选择安装)
或msdn关于visual interdev的文章
相对定位时再加上parseInt(tableid.style.top)|parseInt(tableid.style.left)
Retrieves the calculated left position of the object relative to the layout or coordinate parent。
说明:
You can determine the location, width, and height of an object by using a combination of the offsetLeft, offsetTop, offsetHeight, and offsetWidth properties. These numeric properties specify the physical coordinates and dimensions of the object relative to the object's offset parent. ClientLeft属性:
Retrieves the distance between the offsetLeft property and the true left side of the client area.
区别:
The difference between the offsetLeft and clientLeft properties is the border of the object.
<SCRIPT>
function isinView(oObject)
{
var oParent = oObject.offsetParent;
var iOffsetLeft = oDiv.offsetLeft;
var iClientWidth = oParent.clientWidth;
if (iOffsetLeft > iClientWidth) {
alert("Scroll right for the message.");
}
}
</SCRIPT>
:
<BUTTON onclick="isinView(this)">Click here</BUTTON>
:
<DIV ID=oDiv STYLE="position:absolute; top:200; left:1200;">
:
</DIV>