function $(Id){return document.getElementById(Id)};
function position(elm){
var a = elm.offsetHeight;
var b = elm.offsetWidth;
var c = elm.offsetLeft;
var d = elm.offsetTop;
while(elm=elm.offsetParent){
c += c;
d += d;
};
return [c,d,b,a]
};
alert(position($('ss')));
这样代码不能再少了吧...
变量多是为了后面的代码少啊...
function position(elm){
var a = elm.offsetHeight;
var b = elm.offsetWidth;
var c = elm.offsetLeft;
var d = elm.offsetTop;
while(elm=elm.offsetParent){
c += c;
d += d;
};
return [c,d,b,a]
};
alert(position($('ss')));
这样代码不能再少了吧...
变量多是为了后面的代码少啊...
解决方案 »
- jqgrid中选中某一行,如何实现它的下一级表格根据该行的id更新数据呢?
- 求个匹配指定汉字开头的正则表达式
- 关于<marquee>的一个小问题
- eval()函数的使用问题,很初级,但是我不会
- form提交的怪问题,请大家帮忙!
- 如何得知图片的类型和长宽,高手请入
- window.event 是什么对象啊?
- 新开100分,见 http://expert.csdn.net/Expert/topic/1447/1447612.xml?temp=.3277552
- 请问javascript中的 this 怎么用?
- js获取gridview某行指定的值
- [散分并分享]基于ExplorerCanvas实现跨浏览器绘图:一个表盘时钟
- 怎样让我们伟大的IE做出鼠标经过后改变背景颜色!!!!
d += d;不过这里代码很有问题...
return document.getElementById(Id);
};
function position(elm){
var left = elm.offsetLeft, top = elm.offsetTop;
while (elm = elm.offsetParent)
left += elm.offsetLeft, top += elm.offsetTop;
return [left, top, arguments[0].offsetWidth, arguments[0].offsetHeight];
};
alert(position($('ss')));
<script>
function $(Id){return document.getElementById(Id)};
function position(elm){
var o=elm
var l =o.offsetLeft;
var t =o.offsetTop;
while(o=o.offsetParent){
l += o.offsetLeft;
t += o.offsetTop;
};
return [l,t,elm.offsetWidth,elm.offsetHeight]
};
alert(position($('ss')));
</script>