javascript的几种效果,请教自动判断与浏览器上端的边距,需要支持firefox function getLeft(root){ var left = 0; while(root != null) { left += root.offsetLeft; root = root.offsetParent; } return left; } 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 这个是相对于左边的,或者相对于body顶端的,如果出现滚动条向下拉伸,就是说那个体是窗口是按照当前窗口的上下距离来判断的,可能页面都到最下面了,但是他跟窗口上边距的相对坐标可能是不变的,但是对于窗体的body都有1500px了 下面几个函数,尤其是最后一个 getAvailableHeight 怎么使用的,calBrother,calParent都是bool 型的,但是不知道表示什么意思,怎么使用function findPosX(obj){var curleft=0;if(obj.offsetParent){while(obj.offsetParent){curleft+=obj.offsetLeftobj=obj.offsetParent;}}else if(obj.x)curleft+=obj.x;return curleft;}function findPosY(obj){var curtop=0;if(obj.offsetParent){while(obj.offsetParent){curtop+=obj.offsetTopobj=obj.offsetParent;}}else if(obj.y)curtop+=obj.y;return curtop;}function getDocumentWidth(){var contentWidth;if(window.innerHeight){contentWidth=window.innerWidth-6;}else if(document.documentElement.clientWidth){contentWidth=document.documentElement.clientWidth;}else{contentWidth=document.body.clientWidth;}return contentWidth;}function getDocumentHeight(){var contentHeight;if(window.innerHeight){contentHeight=window.innerHeight-6;}else if(document.documentElement.clientHeight){contentHeight=document.documentElement.clientHeight;}else{contentHeight=document.body.clientHeight;}return contentHeight;}function getAvailableHeight(obj,calBrother,calParent){if(obj.parentNode&&obj.parentNode.tagName&&obj.parentNode.tagName.toLowerCase()!='html'){var y;if(calParent){if(obj.parentNode.style&&obj.parentNode.style.height){y=obj.parentNode.style.height.toLowerCase().split('px')[0];}else{y=obj.parentNode.offsetHeight;}}else{y=getDocumentHeight()-findPosY(obj.parentNode);}if(!calBrother)return y;var brothers=obj.parentNode.childNodes;var b;for(var i=0;i<brothers.length;i++){b=brothers[i];if(b!=obj&&b.nodeType==1&&!(b.style&&b.style.display&&b.style.display=='none')&&b.tagName.toLowerCase()!='script'&&b.tagName.toLowerCase()!='style'){if(b.innerHTML!=''){y-=b.offsetHeight;}}}return y;}else{return null}} js加在顶部,怎么才能控制下面的连接 判断是否在当前周的代码,请帮忙修正 一个简单问题 关于jquery更改html标签问题 求助:网页代码解密 怎么设置cookie,使其关闭浏览器时就失效? 请教:post与get的差别与共同点 网页上增加表单? 如何给一个嵌入页面的pdf加上加载进度条,等待条也可以,加载完成后直接播放pdf? 原生JS实现JSONP跨域访问的问题 只打开一个购物车页面,如何把东西添加到同一个购物车里,不要重复打开购物车页面(内含frame) 在线等!不知道为什么报错,高手指点
{var curleft=0;if(obj.offsetParent){while(obj.offsetParent){curleft+=obj.offsetLeft
obj=obj.offsetParent;}}
else if(obj.x)
curleft+=obj.x;return curleft;}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;}
function getDocumentWidth(){var contentWidth;if(window.innerHeight){contentWidth=window.innerWidth-6;}else if(document.documentElement.clientWidth){contentWidth=document.documentElement.clientWidth;}else{contentWidth=document.body.clientWidth;}
return contentWidth;}function getDocumentHeight(){var contentHeight;if(window.innerHeight){contentHeight=window.innerHeight-6;}else if(document.documentElement.clientHeight){contentHeight=document.documentElement.clientHeight;}else{contentHeight=document.body.clientHeight;}
return contentHeight;}function getAvailableHeight(obj,calBrother,calParent){if(obj.parentNode&&obj.parentNode.tagName&&obj.parentNode.tagName.toLowerCase()!='html'){var y;if(calParent){if(obj.parentNode.style&&obj.parentNode.style.height){y=obj.parentNode.style.height.toLowerCase().split('px')[0];}else{y=obj.parentNode.offsetHeight;}}else{y=getDocumentHeight()-findPosY(obj.parentNode);}if(!calBrother)return y;var brothers=obj.parentNode.childNodes;var b;for(var i=0;i<brothers.length;i++){b=brothers[i];if(b!=obj&&b.nodeType==1&&!(b.style&&b.style.display&&b.style.display=='none')&&b.tagName.toLowerCase()!='script'&&b.tagName.toLowerCase()!='style'){if(b.innerHTML!=''){y-=b.offsetHeight;}}}
return y;}else{return null}}