用JavaScript判定瀏覽器是否為IE

摘自 http://leeiio.me/ie_detection_in_5_bytes/

<script type='text/javascript'>  
var ie = !-[1,];  
alert(ie);  
</script>

以上程式碼執行結果:IE 下返回 true,其他標準瀏覽器返回 false。!-[1,],僅僅只有 6 bytes!

<script type='text/javascript'>  
// Option from Dean Edwards:  
var ie = /*@cc_on!@*/false;  

// Use the commented line:  
var ie//@cc_on=1;  

// Variation (shorter variable):  
var ie = '\v'=='v';  

// Option to Gareth Hayes (former record-holder):  
var ie = !+"\v1";  
</script>

Last modified on 2010-04-15