HanG321 Blog
Be Shine, Be Smile, Be Wild
  • Home
  • Blog
    • 好文閱讀 readings
    • 生活記事 diary
    • 時事評論 commentary
    • 科技資訊 technology
    • 電腦編程 programming
    • 金融財經 finance
    • 音樂電影 music/movie
  • About

Detect IE version

May 30, 2007|IE, Javascript|電腦編程
Home » Blog » 電腦編程 » Detect IE version
JavaScript
1
2
3
4
var is_ie/*@cc_on = {
// quirksmode : (document.compatMode=="BackCompat"),
version : parseFloat(navigator.appVersion.match(/MSIE (.+?);/)[1])
}@*/;
 

(Uncomment the second line if you also wish to check whether IE is running in “compatibility” (quirks) mode or in standards-mode.)

All other browsers cheerfully ignore the Javascript comment block (/* … */) so what they end up with is essentially this:

var is_ie;

…which evaluates as an implicit false, when used as a condition. This allows us to set up conditions like this one:

JavaScript
1
2
3
4
5
6
7
8
9
10
11
12
if (is_ie && (is_ie.version < 7))
{
// do IE specific stuff
}
else if (is_ie && (is_ie.version >= 7))
{
//do IE 7 or above specific stuff
}
else
{
// default behavior for other browsers
}

 

[reference : http://mar.anomy.net/entry/2006/11/23/00.06.40/ ]


Technorati : IE, javascript, version

May 30, 2007 user

Related Posts

  • DWA: IE7 fixes for Domino 6.5.5
    DWA: IE7 fixes for Domino 6.5.5May 29, 2007
  • javascript: rotate image with jQuery library
    javascript: rotate image with jQuery libraryMay 28, 2007
  • IE7 FrameSet
    IE7 FrameSetFebruary 12, 2007

Popular Posts

  • Install XPEnology (DSM) 5.1 on ESXi 6 (HP MicroServer Gen 8)
    Install XPEnology (DSM) 5.1 on ESXi 6 (HP MicroServer Gen 8)June 8, 2015
  • assembly
    assemblyFebruary 11, 2006
  • 呢幾日個blogger 有問題….
    呢幾日個blogger 有問題….October 28, 2004
← DWA: IE7 fixes for Domino 6.5.5
below mean →

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.




最新文章 Recent Posts

  • Serverless Cloud Run Development: Challenge Lab
  • ionic 4: capacitor & pwa
  • Open file limit of tomcat and mysql in Linux server
  • avoid subquery in mysql update statement
  • hacktoberfest

最新留言 Recent Comments

  • admin on LikeCoin
  • Edmond on LikeCoin
  • John Smith on Install macOS High Sierra on VMware
  • admin on Install macOS High Sierra on VMware
  • nana on Install macOS High Sierra on VMware




熱門文章 Popular Posts

  • Install XPEnology (DSM) 5.1 on ESXi 6 (HP MicroServer Gen 8)
    Install XPEnology (DSM) 5.1 on ESXi 6 (HP MicroServer Gen 8) June 8, 2015
  • 呢幾日個blogger 有問題….
    呢幾日個blogger 有問題…. October 28, 2004
  • assembly
    assembly February 11, 2006
  • 新工作
    新工作 January 6, 2009
  • 嫁人要嫁工程師
    嫁人要嫁工程師 April 27, 2006

標籤雲 Tag Cloud

CentOS Character chroot Cluster crash cryptography DD-WRT debug Domino DSM Dual Core DWA email ESXi GCP git google HylaFax IE Java Javascript JRE LikeCoin Linux log LotusScript mint MX MySQL nginx PKI PowerShell Qwiklabs srt telent VMware vpn vSphere WinXP wordpress XPEnology 專欄 網絡資訊 選股 風帆

日曆 Calendar

May 2007
M T W T F S S
  « Apr   Jun »  
 123456
78910111213
14151617181920
21222324252627
28293031  

Follow Me

Follow Us on RSSFollow Us on TwitterFollow Us on YouTube

文章存檔 Archives

Copyright © 2004-2021 hang321.net. All Rights Reserved