首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

jquery 解决ie6.0 position:fixed bug,该怎么解决

2012-06-04 
jquery 解决ie6.0 position:fixed bugHTML code!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN

jquery 解决ie6.0 position:fixed bug

HTML code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.3/jquery.min.js" type="text/javascript"></script><title>IE6 position:fixed bug</title><style>     #floatDiv{width:150px; height:50px; background:green;} </style><script type="text/javascript">$(function(){    if($.browser.msie && $.browser.version=="6.0"){        var div1 = "<div style='position:absolute; right:10px; top:expression(documentElement.scrollTop+documentElement.clientHeight-this.offsetHeight-10)'></div>";        $("#floatDiv").wrap(div1);    }})</script></head><body>    <div id="floatDiv"></div>        <p style="height:1500px;"></p></body></html>



以上代码,IE6.0老报错(IETester测试),我应该怎样 将一个 对象 包含在

<div style="position:absolute; right:10px; top:expression(documentElement.scrollTop+documentElement.clientHeight-this.offsetHeight-10)"></div>

标签内,如下:
HTML code
<div style='position:absolute; right:10px; top:expression(documentElement.scrollTop+documentElement.clientHeight-this.offsetHeight-10)'>    <div id="floatDiv"></div></div>




[解决办法]
表达式 不能写在行内样式中吧。

HTML code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" />        <script src="http://code.jquery.com/jquery-latest.js"></script><title>IE6 position:fixed bug</title><style>     #floatDiv{width:150px; height:50px; background:green;}         .test {        top:expression(documentElement.scrollTop+documentElement.clientHeight-this.offsetHeight-10)    }    </style><script type="text/javascript">$(function(){    if($.browser.msie && $.browser.version=="6.0"){        var div1 = "<div style='position:absolute; right:10px; ' class='test'></div>";        $("#floatDiv").wrap(div1);    }})</script></head><body>    <div id="floatDiv"></div>        <p style="height:1500px;"></p></body></html>
[解决办法]
注意quirks文档

热点排行