pixelLeftSets or retrieves the left position of the element, in pixels. Unlike the left property, this property's value is an integer, not a string, and is always interpreted in pixels. scrollLeftSets or retrieves the distance, in pixels, between the left edge of the element and the leftmost portion of the element that is currently visible in the window. This is equal to the horizontal distance that the content of the element has been scrolled.
pixelLeft:相对于某点(一般是屏幕左上角)的水平距离。
根据我上面从HTMLREF.CHM里面摘抄的解释,scrollLeft应该是水平滚动条已经滚动的距离(元素左边界与可见部分的最左边的横坐标差),而不是总长度。
水平滚动条总长度应该是scrollWidth才对。
我检讨~~~
scrollTop:垂直滚动条已经滚动的距离
scrollHeight:垂直滚动条总长度
scrollLeft:水平滚动条已经滚动的距离
scrollWeight:水平滚动条总长度当时没看清楚,sorry~~
多谢Estyle(靳田)提醒!
<form name="form1" method="post" action="">
<div align="center">
<textarea name="textarea" rows="10"></textarea>
<br>
<input type="button" name="button" value="按钮" onclick="alert(textarea.scrollTop);">
</div>
</form>先直接按一下,按扭,然后再添加n行文字,使scroll出来,然后滚动一下scroll再按按钮,现在你肯定已经明白了!