document.execCommand("BackgroundImageCache",false)
2013-09-12 10:44
627 查看
很多时候,我们给按钮或者图片设置背景,但为了样式和结构分离,通常背景都在css里面设置,但是IE这一行为会有一个bug,那就是因为IE在默认的情况下,不缓存背景图片。所以当鼠标在有css背景的按钮或者图片移动的时候,图片会闪烁甚至鼠标会出现忙的状态。而在FireFox下没有这个问 题,为了解决这个问题,有两种解决办法,其一是在CSS中加入如下样式:
但这个 可能会使整个页面加载变得很慢,所以推荐使用JS修正这个bug,在页面中的任意位置加入如下代码,即可达到理想中的效果:
html{filter:expression:document.execCommand("BackgroundImageCache",false,true);}
但这个 可能会使整个页面加载变得很慢,所以推荐使用JS修正这个bug,在页面中的任意位置加入如下代码,即可达到理想中的效果:
(function() { var browser = {}; browser.name = navigator.appName; if (browser.name.indexOf("Microsoft") != -1) { browser.msie = navigator.appVersion.indexOf("MSIE"); browser.version = parseInt(navigator.appVersion.substring(browser.msie + 4)); if (browser.version <= 6) { document.execCommand("BackgroundImageCache", false, true); } } })(window.navigator) //闭包传参
相关文章推荐
- html{filter:expression(document.execCommand("BackgroundImageCache",false,true)
- IE6下背景图片不缓存问题或者document.execCommand("BackgroundImageCache",false,true)
- document.execCommand("BackgroundImageCache", false, true)
- IE图片缓存document.execCommand("BackgroundImageCache",false,true)
- IE6下背景图片不缓存问题或者document.execCommand("BackgroundImageCache",false,true)
- document.execCommand("BackgroundImageCache",false,true)
- filter:expression(document.execCommand("BackgroundImageCache",false,true) 转
- .document.execCommand("BackgroundImageCache",false,true)解决ie6下的背景图片缓存问题
- document.execCommand("BackgroundImageCache",false,true)解决ie6下的背景图片缓存问题
- document.execCommand(”BackgroundImageCache”, false, true)
- ie6背景图片不缓存bug处理document.execCommand('BackgroundImageCache', false, true)
- document.execCommand(”BackgroundImageCache”, false, true)
- IE6下默认不缓存背景图片document.execCommand("BackgroundImageCache", false, true); "转载"
- window.document.execCommand("SaveAs",false,id+".xls"); 在IE7下的问题
- 利用IE"错觉"实现document.execCommand("SaveAs","","") 默认保存为GB2312 格式
- document.execCommand()的用法小记
- 简易博客编辑器:玩转document.execCommand命令
- document.execCommand()函数可用参数解析
- document.execCommand()函数可用参数
- document.execCommand()函数可用参数解析 (转)