Skip to content

Instantly share code, notes, and snippets.

@wangwen1220
Created January 4, 2014 01:34
Show Gist options
  • Save wangwen1220/8250306 to your computer and use it in GitHub Desktop.
Save wangwen1220/8250306 to your computer and use it in GitHub Desktop.
JS: 检测浏览器 | test browser
/* IE 6 */
(checkIE = document.createElement("b")).innerHTML = "<!--[if IE 6]><i></i><![endif]-->";
var isIE = checkIE.getElementsByTagName("i").length == 1;
/* IE 7 */
(checkIE = document.createElement("b")).innerHTML = "<!--[if IE 7]><i></i><![endif]-->";
var isIE = checkIE.getElementsByTagName("i").length == 1;
navigator.appVersion.indexOf("MSIE 7.")!=-1
/* IE 8 */
(checkIE = document.createElement("b")).innerHTML = "<!--[if IE 8]><i></i><![endif]-->";
var isIE = checkIE.getElementsByTagName("i").length == 1;
/* IE 9 */
(checkIE = document.createElement("b")).innerHTML = "<!--[if IE 9]><i></i><![endif]-->";
var isIE = checkIE.getElementsByTagName("i").length == 1;
/* IE 10 */
var isIE = eval("/*@cc_on!@*/false") && document.documentMode === 10;
/* IE 10 */
var isIE = document.body.style.msTouchAction != undefined;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment