IE6下CSS背景图片的Bug
2007-11-27 21:23 | Filed Under Html/JS/CSS |
最近碰到的问题,比如有一div,设置了背景图,然后只要在js中对此div的css做出任何更改就会重新请求背景图片,表现为页面闪烁
此问题仅在IE6下出现(更低版本未测试),原因是IE6在默认情况下不缓存背景图片
解决办法一,通过css:
filter: expression(document.execCommand("BackgroundImageCache", false, true));
}
缺点:可能会使整个页面的加载速度变慢
解决办法二,使用javascript:
document.execCommand(“BackgroundImageCache”, false, true);
</script>
缺点:如果在firefox等浏览器下执行会出错。
所以需要判断是否为IE浏览器,使用jQuery提供的判断方法如下:
if ($.browser.msie) {
document.execCommand(“BackgroundImageCache”, false, true);
}
</script>
相关日志
jQuery实现checkbox全选
2007-11-08 22:57 | Filed Under Html/JS/CSS |
jQuery的选择器确实很强大,比起自己实现能节约不少代码
- <script type="text/javascript">
- $(function() {
- $("#selectall").click(function() {
- $("input[@name='shareuser[]']").each(function() {
- $(this).attr("checked", true);
- });
- });
- $("#deselectall").click(function() {
- $("input[@name='shareuser[]']").each(function() {
- $(this).attr("checked", false);
- });
- });
- });
- </script>
- <input type='checkbox' id='in-shareuser-10' name='shareuser[]' value='10' />UserA
- <input type='checkbox' id='in-shareuser-11' name='shareuser[]' value='11' />UserB
- <input type='checkbox' id='in-shareuser-12' name='shareuser[]' value='12' />UserC
- <input type="button" id="selectall" name="selectall" value="全选" />
- <input type="button" id="deselectall" name="deselectall" value="取消全选" />
相关日志
Documents
2006-09-09 14:25 | Filed Under Life |
- 正则表达式语法
- Html/Javascript/CSS Online Documents
- jQuery Docs - 1.1.2 API
- Struts Taglib Reference
- Visual jQuery 1.1(中文版)
- W3Schools Online Web Tutorials 中文版
相关日志



