1<body>
<script>
function position(obj){
with(obj){
x=offsetLeft;
y=offsetTop;
objParent=offsetParent;
while(objParent.tagName.toUpperCase()!= "BODY"){
x+=objParent.offsetLeft;
y+=objParent.offsetTop;
objParent = objParent.offsetParent;
}
}
alert('x:'+x+'\ny:'+y)
}
</script>
<input onclick=position(this)>
</body>
2.我试过可以啊
<script>
function position(obj){
with(obj){
x=offsetLeft;
y=offsetTop;
objParent=offsetParent;
while(objParent.tagName.toUpperCase()!= "BODY"){
x+=objParent.offsetLeft;
y+=objParent.offsetTop;
objParent = objParent.offsetParent;
}
}
alert('x:'+x+'\ny:'+y)
}
</script>
<input onclick=position(this)>
</body>
2.我试过可以啊
var l=obj.offsetLeft;
var t=obj.offsetTop;
while (obj = obj.offsetParent){t+=obj.offsetTop; l+=obj.offsetLeft;}
<!--来自梅花雨日历控件,可是我看不懂:( -->第二个问题,我再看看
想要拿这100分,你得解释offsetParent的详细意义