当前位置:
首页 >
首页 > doctype后如何获得body.clientHeight的方法 文章详情
doctype后如何获得body.clientHeight的方法
分类:首页
标签Tags:doctype,如何,获得,body,方法,ie,js,脚本,执行,就会,出现问题,一般,是在,获取,clientwidth,offsetwidth,scrollwidth
在ie6中很多js脚本执行就会出现问题,一般是在获取clientWidth, clientHeight,offsetWidth, offsetHeight,scrollWidth, scrollHeight,scrollTop, scrollLeft会返回不正确的值。
因为在加了doctype后,在ie6中这些document.body的属性已经重新分配给了document.documentElement。
比如:原来document.body.clientHeight,就要改成document.documentElement.scrollTop
为了自适应,可以改了下代码:
((document.documentElement.clientHeight==0)?document.body.clientHeight:document.documentElement.clientHeight)
用这样的代码就能自适应了。
以上就是【doctype后如何获得body.clientHeight的方法】的全部内容了,欢迎留言评论进行交流!
与本文相关的软件