没有指定一个div块的top,left等属性,如果取得该div块的top,left属性。 <br><div id=t></div><script>alert(document.all.t.style.pixelTop)</script> 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <br><div id=t></div><script>alert(document.all.t.offsetTop)alert(document.all.t.clientTop)alert(document.all.t.style.posTop)</script> 看你的需求了,想得到什么样的top值默认的top是auto自动获取当前位置document.all.t.currentStyle.top如果是left把所有的Top改称Left <div id=movingDiv class=movingDiv style="VISIBILITY: hidden; POSITION: absolute; z-index:100"><table width=80>aa</table></div> <div id="docID<%=rs("docID").Value%>" style="cursor:hand; "><%=strtitle%></div>movingDiv的top是335px,单位是像素;另一个div块:如docID5,取:document.all.docID5.offsetTop的单位不是像素。我想比较一下这两个div块的高度。 <p>测试<p>测试<div id=movingDiv class=movingDiv style="VISIBILITY: hidden; POSITION: absolute; z-index:100"><table width=80>aa</table></div> <div id="docIDa" style="cursor:hand; ">ddddd</div><input onclick="alert(movingDiv.offsetTop);alert(docIDa.offsetTop)" type=button value=" 测试 "> 这样两个div块的top不是比不出来了吗?都是64 去http://www.eb-star.net/tech/designxp/default.asp自己研究代码,可以把div在页面任意拖拽定位,并且可以记忆。 但实际上它也都在那个位置不过可以通过他们的zIndex来区分 是这样的:docID5放在表格td里面,movingDiv没有放在表格里面。使用docID5.offsetTop仅仅取得这个div块相对于它所在的td的top,不能和movingDiv.style.pixelTop相比。我说要做的是比较这两个div快的高度差,谁在上面,谁在下面。 <p>测试<p>测试<div id=movingDiv class=movingDiv style="VISIBILITY: hidden; POSITION: absolute; z-index:100"><table width=80>aa</table></div> <table><td><div id="docIDa" style="cursor:hand; ">ddddd</div></td></table><input onclick="alert(getTop('docIDa'));alert(getTop('movingDiv'))" type=button value=" 测试 "><script>function getTop(str){var e=document.all(str);var t=e.offsetTop;while(e=e.offsetParent)t+=e.offsetTop;return t;}</script> 用js如何设置我的页面为首页,代码如何写啊 怎样让浏览器地址栏显示值改变但不跳转? 一个表格中如何同时存在行表头和列表头 请问怎么使鼠标不能移到一个disabled的文本框上 各位,我用javascript写了树状菜单,大侠帮我改下 Highcharts 在IE8上渲染动画问题 js中用什么方法删除字符串中头,尾的空格? 还有isNaN问题请教 页面刷新后列表框的值被置空了 一个刷新的问题 javascript中如何将重复的语句提炼为一个方法进行调用 请教高手几个问题 判断日期类型的问题
<div id=t></div>
<script>
alert(document.all.t.offsetTop)
alert(document.all.t.clientTop)
alert(document.all.t.style.posTop)
</script>
document.all.t.currentStyle.top如果是left把所有的Top改称Left
<div id=movingDiv class=movingDiv style="VISIBILITY: hidden; POSITION: absolute; z-index:100"><table width=80>aa</table></div>
<div id="docIDa" style="cursor:hand; ">ddddd</div>
<input onclick="alert(movingDiv.offsetTop);alert(docIDa.offsetTop)" type=button value=" 测试 ">
docID5放在表格td里面,
movingDiv没有放在表格里面。
使用docID5.offsetTop仅仅取得这个div块相对于它所在的td的top,
不能和movingDiv.style.pixelTop相比。我说要做的是比较这两个div快的高度差,谁在上面,谁在下面。
<div id=movingDiv class=movingDiv style="VISIBILITY: hidden; POSITION: absolute; z-index:100"><table width=80>aa</table></div>
<table><td>
<div id="docIDa" style="cursor:hand; ">ddddd</div></td></table>
<input onclick="alert(getTop('docIDa'));alert(getTop('movingDiv'))" type=button value=" 测试 ">
<script>
function getTop(str){
var e=document.all(str);
var t=e.offsetTop;
while(e=e.offsetParent)t+=e.offsetTop;
return t;
}
</script>