IE6下CSS背景图片的Bug

最近碰到的问题,比如有一div,设置了背景图,然后只要在js中对此div的css做出任何更改就会重新请求背景图片,表现为页面闪烁
此问题仅在IE6下出现(更低版本未测试),原因是IE6在默认情况下不缓存背景图片

解决办法一,通过css:

html {
    
filter: expression(document.execCommand("BackgroundImageCache", false, true));
}

缺点:可能会使整个页面的加载速度变慢

解决办法二,使用javascript:

<script type='text/javascript'>
document.execCommand(BackgroundImageCache”, false, true);
<
/script>

缺点:如果在firefox等浏览器下执行会出错。
所以需要判断是否为IE浏览器,使用jQuery提供的判断方法如下:

<script type='text/javascript'>
if ($.browser.msie) {
    
document.execCommand(BackgroundImageCache”, false, true);
}
<
/script>
标签:, , , , , ,

相关日志

jQuery实现checkbox全选

jQuery的选择器确实很强大,比起自己实现能节约不少代码

  1. <script type="text/javascript">
  2. $(function() {
  3.     $("#selectall").click(function() {
  4.         $("input[@name='shareuser[]']").each(function() {
  5.             $(this).attr("checked", true);
  6.         });
  7.     });
  8.     $("#deselectall").click(function() {
  9.         $("input[@name='shareuser[]']").each(function() {
  10.             $(this).attr("checked", false);
  11.         });
  12.     });
  13. });
  14. </script>
  15.  
  16. <input type='checkbox' id='in-shareuser-10' name='shareuser[]' value='10' />UserA
  17. <input type='checkbox' id='in-shareuser-11' name='shareuser[]' value='11' />UserB
  18. <input type='checkbox' id='in-shareuser-12' name='shareuser[]' value='12' />UserC
  19.  
  20. <input type="button" id="selectall" name="selectall" value="全选" />
  21. <input type="button" id="deselectall" name="deselectall" value="取消全选" />
标签:, ,

相关日志

Documents

标签:, , , , ,

相关日志

京ICP备05059555号