作家
登录

Code:findPosX 和 findPosY

作者: 来源:www.28hudong.com 2013-03-30 03:55:25 阅读 我要评论

/** * Find the X position of an object, relative to the viewport * Code copied from quirksmode.org * @param obj Object to find x position for */ function findPosX(obj) { var curleft = 0; if (obj.offsetParent) { while (obj.offsetParent) { curleft += obj.offsetLeft obj = obj.offsetParent; } } else if (obj.x) curleft += obj.x; return curleft; } /** * Find the Y position of an object, relative to the viewport * Code copied from quirksmode.org * @param obj Object to find y position for */ function findPosY(obj) { var curtop = 0; if (obj.offsetParent) { while (obj.offsetParent) { curtop += obj.offsetTop obj = obj.offsetParent; } } else if (obj.y) curtop += obj.y; return curtop; }

  推荐阅读

  论坛特效代码收集(落伍转发-不错)

1.overflow内容溢出时的设置(设定被设定对象是否显示滚动条) overflow-x水平方向内容溢出时的设置 overflow-y垂直方向内容溢出时的设置 以上三个属性设置的值为visible(默认值)、scroll、hidden、auto。 2.scr>>>详细阅读


本文标题:Code:findPosX 和 findPosY

地址:http://www.17bianji.com/kaifa2/JS/31298.html

关键词: 探索发现

乐购科技部分新闻及文章转载自互联网,供读者交流和学习,若有涉及作者版权等问题请及时与我们联系,以便更正、删除或按规定办理。感谢所有提供资讯的网站,欢迎各类媒体与乐购科技进行文章共享合作。

网友点评
自媒体专栏

评论

热度

精彩导读
栏目ID=71的表不存在(操作类型=0)