doctype后如何获得body.clientHeight的方法

时间:2007-07-11    点击:116   
在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)


用这样的代码就能自适应了。

Locate a File Using a File Open Dialog Box
firefox中用javascript实现鼠标位置的定位
Sample script that displays all of the users in a given SQL Server DB
JTrackBar水平拖动效果
抽出www.templatemonster.com的鼠标悬停加载大图模板的代码
> 返回     
地址:上海市普陀区胶州路941号长久商务中心 电话: QQ:
© Copyright 2012 上海网络 Product All Rights Reserved