2007年8月25日星期六

IE支持~~~

貌似前几天的代码对IE支持有点不好,貌似是因为window.innerWidth在IE里面不支持...

查了一下,有这么一篇文章《web技术研究与应用

var windowWidth; // frame width & height

if(window.innerWidth){
windowWidth=window.innerWidth;
} else if(document.documentElement &&
document.documentElement.clientWidth){
windowWidth=document.documentElement.clientWidth;
} else if(document.body){
windowWidth=document.body.offsetWidth;
}


但是貌似没法直接用:(
不过尝试了一下,如果简单的用window.innerWidth替换document.documentElement.clientWidth,貌似至少对于IE和firefox就都好用了,所以最后的代码就是~~


<script type='text/javascript'>
//<![CDATA[
document.writeln("<style type=\"text/css\">#main-wrapper {width:" + ((document.documentElement.clientWidth)*0.92 - 348) + "px;}</style>");//set main width
//]]>
</script>

0 comments: