ie重复加载相同背景图片的bug

这是我使用的jquery滑动菜单的代码,在css中加载菜单项目的背景图片及菜单项的小图片,但是在使用时会反复从服务器请求那两个图片,

<script type="text/javascript">
        $(document).ready(
 function () {
     $(".menuTitle").click(function () {
         $(this).next("div").slideToggle("slow")
   .siblings(".menuContent:visible").slideUp("slow");
         $(this).toggleClass("activeTitle");
         $(this).siblings(".activeTitle").removeClass("activeTitle");

     });
 });
</script>

body
 {
  margin:0;background-color:#9ad075;
 }
 .container
 {
  width:100%; text-align:center;
 }
 .menuTitle
 {
  width:148px; height:25px; background-image:url(images/expand.gif); margin:0 auto; line-height:25px; font-size:12.7px; font-weight:bold;color:#43860c; cursor:pointer; margin-top:6px;
 }
 .activeTitle
 {
  width:148px; height:25px; background-image:url(images/fold.gif); margin:0 auto; line-height:25px; font-size:12.7px; font-weight:bold;color:#43860c; cursor:pointer; margin-top:6px;
 }
 .menuContent
 {
  background-color:#fff; margin:0 auto; height:auto; width:148px; text-align:left; display:none;
 }
 li
 {
   background:url(images/arr.gif) no-repeat 20px 6px ; list-style-type:none;padding:0px 0px 0px 38px; font-size:13px; height:26px; line-height:26px;
 }
 li a:hover,a:active
 {
  color:Red;
  font-size:14px;
  font-weight:bold; 
 }
 ul
 {
  margin:0;padding:0;
 }

经过网上反复查找,正确的解决办法是在css代码顶部添加下面的代码就可以了,据说在ie7中这个bug已经修复!

html {
    zoom: expression(function(ele){
 ele.style.zoom = "1";
 document.execCommand("BackgroundImageCache", false, true);
    }(this));
    }

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值