让IE6支持HTML5元素的方法

作者已经把这段代码放到了Google code project上,只需要在你的head中调用这段代码就行: 

<!--if lt IE 9]> 
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> 
<!--endif]--> 
当然你也可以直接把这个文件下载到自己的网站上。这个文件必须在head标签中调用,因为IE必须在元素解析这前知道这些元素,才能启作用!或许你还要在你的CSS文件中加上以下代码,不然有可能会出现些莫名其妙的问题。 

header,nav,article,section,aside,footer{display:block;} 
另外excanvas.js是Google为IE6支持canvas元素写的脚本,里面有很详细的例子,感兴趣的朋友可以去试试。 

Kill IE6 

我也厌烦了IE6的特殊,所以也加了KILL IE6一族,所有用IE6访问我的网站的朋友都会出Kill IE6的对话框,前提是你的浏览器允许执行JS文件。方法很简单,在你的网站的</body>之前加上以下代码就可以了: 

<!--if lte IE 6]> 
<script src="http://letskillie6.googlecode.com/svn/trunk/letskillie6.zh_CN.pack.js"></script>
<!--endif]--> 
IE中的判断语句 

上面写的<!--if lte IE 6]>在正常的HTML中属于注释,不会被执行,但在IE中是一个判断语句,所以这些代码只有在IE中才会被识别并加载。 

lte:就是Less than or equal to的简写,也就是小于或等于的意思。 

lt :就是Less than的简写,也就是小于的意思。 

gte:就是Greater than or equal to的简写,也就是大于或等于的意思。 

gt :就是Greater than的简写,也就是大于的意思。 

! : 就是不等于的意思,跟javascript里的不等于判断符相同




另外一个兼容ie6~8的还有一个 ie7-js的脚本可以是

https://code.google.com/p/ie7-js/


IE9.js

Upgrade MSIE5.5-8 to be compatible with modern browsers.

<!--[if lt IE 9]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
<![endif]-->

PNG

The script only fixes images named: *-trans.png

If you want the fix to apply to all PNG images then set a global variable as follows:

var IE7_PNG_SUFFIX = ".png";

You must set this variable before including the IE7.js script. Alternatively, you can set the variable inside the IE7.js script element:

<script src="IE8.js">IE7_PNG_SUFFIX=".png";</script>

The suffix will ignore query string parameters. For more fine-grained control you can also set IE7_PNG_SUFFIX to a RegExp object. If you want to use an alternative PNG solution then set the suffix to something that cannot possibly match:

var IE7_PNG_SUFFIX = ":";

By default, the PNG will be stretched (this simulates tiling). If you want to turn this off then set the no-repeat property as follows:

div.example {
  background: url(my-trans.png) no-repeat;
}

Unfortunately, the transparent background image cannot be tiled (repeated) using background-repeat. Nor can it be positioned usingbackground-position.




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值