js 一些兼容检测
1、
IE5.0之前不支持 document.getElementById(),但存在 document.all[]
function getElementById(id) { if(document.getElementById){ return document.getElementById(id); }else if(document.all) { return document.all[id]; }else{ throw Error("No way to retrieve element"); } }
2、
IE8及之前的版本中,typeof document.createElement 返回的是 “object”,而不是 “function”
function isHostMethod(object,property){ var t = typeof object[property]; return t=='function' || (!!(t=='object' && object[property])) || 'unknown'; }
3、
IE8及之前的版本中,如果某个实例属性与[[Enumerable]]标记为false的某个原型属性同名,name该属性将不会出现在 for-in 循环中。
var hasDontEnumQuirk = function () { var o = { toString: function(){}}; for(var prop in o){ if(prop == "toString"){ return false; } } return true; }();

浙公网安备 33010602011771号