网站切换背景时,浏览器图片缓存问题

方法一: 

 //为解决缓存问题,先Remove然后然后添加时间戳
        //$("#Loginbg").remove();
        //$("#formLogin").before('<img class="backgroundImg" id="Loginbg" src="images/Index/bg_index' + type + '.png?r=<%=System.currentTimeMillis()%>"/>');

方法二:
        //为解决缓存问题,必须添加时间戳
        $("#Loginbg").attr("src", "images/Index/bg_index" + type + ".png?r=" + new Date().toString());

猜你喜欢

转载自www.cnblogs.com/johnblogs/p/10278802.html