while(e = e.offsetParent)
{}====CSDN====
人生起起伏伏凑字凑
{}====CSDN====
人生起起伏伏凑字凑
解决方案 »
- 关于浏览器自动记住登录帐号和密码后, 一些输入框会显示帐号密码信息
- 动态元素id获取的问题
- jquery鼠标拖动层的代码+问题
- 高分求教shadowbox js调用方法。SOS
- (大家来试试)最简洁的浏览器判断语句
- 一个关于js控制tree展开关闭的问题
- 高手帮我看看这是什么方式加密的~~~
- 哇塞!以前没有发现的问题!!
- 求在表单的提交按钮按下后使其失效的完整代码或者请请帮助修改我写好的代码段
- 请问如何屏蔽IE工具栏中的后退和前进按钮?
- 能否使用XMLHTTP发送文件,还有为什么我使用XMLHTTP post汉字到php的服务器接受到的总是乱码
- 怎样用javascript,通过ocx控件的ID判断该控件是否注册??????
{
_left = 0
while(e = e.offsetParent)
{
_left += e.offsetLeft
}
return _left
}====CSDN====
人生起起伏伏凑字凑
{
_left = e.offsetLeft
while(e = e.offsetParent)
{
_left += e.offsetLeft
}
return _left
}====CSDN====
人生起起伏伏凑字凑
//得到控件的绝对位置
function getctrlPosition(obj,pos){
var t=eval("obj."+pos);
while(obj=obj.offsetParent){
t+=eval("obj."+pos);
}
return t;
}
function getctrlPosition(obj,pos)参数说明:
obj:对象,目标控件
pos:字符串,"offsetLeft" 或 "offsetTop"
function Rect(){
this.width=0;
this.height=0;
this.left=0;
this.top=0;
this.right=0;
this.bottom=0;
}
Rect.prototype.Cal=function () {
this.right=this.left+this.width;
this.bottom=this.top+this.height;
}
Rect.prototype.ContaintPoint=function (x,y){
if(x>=this.left && x<=this.right && y>=this.top && y<=this.bottom) return true;
return false;
}
Rect.prototype.BeCoverBy=function (rectSrc){
return rectSrc.ContaintPoint(this.left,this.top) ||
rectSrc.ContaintPoint(this.left,this.bottom) ||
rectSrc.ContaintPoint(this.right,this.top) ||
rectSrc.ContaintPoint(this.right,this.bottom) ||
this.ContaintPoint(rectSrc.left,rectSrc.top) ||
this.ContaintPoint(rectSrc.right,rectSrc.top) ||
this.ContaintPoint(rectSrc.left,rectSrc.bottom) ||
this.ContaintPoint(rectSrc.right,rectSrc.bottom);
}
//获取一个HTML对象的RECT属性
function getElementRect(obj){
var e=obj;
var pos=new Rect;
pos.width=obj.offsetWidth;
pos.height=obj.offsetHeight;
pos.left=obj.offsetLeft;
pos.top=obj.offsetTop;
while(e=e.offsetParent){
pos.left+=e.offsetLeft;
pos.top+=e.offsetTop;
}
pos.Cal();
return pos;
}