Skip to content

Commit 1f90115

Browse files
committed
Add default detection for IE 9 and IE 10
How it's done: On IE10, which should come first before the IE 9 check, the nodeName function always returns the name in uppercase. One IE9, the "Object doesn't support property or method" error always repeats the name of the invalid method.
1 parent 6c36d14 commit 1f90115

File tree

1 file changed

+25
-7
lines changed

1 file changed

+25
-7
lines changed

data/js/detect/os.js

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -945,14 +945,32 @@ window.os_detect.getVersion = function(){
945945
if (!ua_version) {
946946
// The ScriptEngine functions failed us, try some object detection
947947
if (document.documentElement && (typeof document.documentElement.style.maxHeight)!="undefined") {
948+
// IE 10 detection using nodeName
949+
if (document.createElement("badname").nodeName == "BADNAME") {
950+
ua_version = "10.0";
951+
}
952+
953+
// IE 9 detection based on a "Object doesn't support property or method" error
954+
if (!ua_version) {
955+
try {
956+
document.BADNAME();
957+
} catch(e) {
958+
if (e.message.indexOf("BADNAME") > 0) {
959+
ua_version = "9.0";
960+
}
961+
}
962+
}
963+
948964
// IE8 detection straight from IEBlog. Thank you Microsoft.
949-
try {
950-
ua_version = "8.0";
951-
document.documentElement.style.display = "table-cell";
952-
} catch(e) {
953-
// This executes in IE7,
954-
// but not IE8, regardless of mode
955-
ua_version = "7.0";
965+
if (!ua_version) {
966+
try {
967+
ua_version = "8.0";
968+
document.documentElement.style.display = "table-cell";
969+
} catch(e) {
970+
// This executes in IE7,
971+
// but not IE8, regardless of mode
972+
ua_version = "7.0";
973+
}
956974
}
957975
} else if (document.compatMode) {
958976
ua_version = "6.0";

0 commit comments

Comments
 (0)