2014年2月12日 星期三

IE Conditional Comments

之前看到有人使用IE特有的條件注釋,
一直到IE 9都有支援,從IE 10開始取消

IE條件注釋
<!--[if IE]><![endif]-->

非IE瀏覽器寫法
<!--[if !IE]><!--> 除IE外都可識別 <!--<![endif]-->



lt:less than
lte:less than or equal
gt:greater than
gte:greater than or equal


實際可以應用在jQuery上
jQuery 2.0開始不支援IE8以下
但是2.0和1.9的用法相同
所以為了依據不同瀏覽器使用最佳的jQuery
就可以使用:
<!--[if lt IE 9]>
<script src="jquery-1.9.0.js"></script>
<![endif]-->
<!--[if gte IE 9]><!-->
<script src="jquery-2.0.0.js"></script>
<!--<![endif]-->

詳細說明:
可以參考wiki
http://zh.wikipedia.org/wiki/%E6%9D%A1%E4%BB%B6%E6%B3%A8%E9%87%8A
這篇說的不錯
http://rritw.com/a/bianchengyuyan/C__/20130517/354044.html
這篇有提到JS的條件注釋
http://blog.xuite.net/vexed/tech/59857067