对象特征检测法判断浏览器对javascript对象的支持_javascript技巧
来源:懂视网
责编:小采
时间:2020-11-27 20:43:38
对象特征检测法判断浏览器对javascript对象的支持_javascript技巧
对象特征检测法判断浏览器对javascript对象的支持_javascript技巧: 代码如下: if(document.getElementById) { alert(document.getElementById);//output: function getElementById(){ [native code] }; } 如上例,该方法判断所在浏览器是否支持getElementById()方法,注意,这里if语句中的检测对象没
导读对象特征检测法判断浏览器对javascript对象的支持_javascript技巧: 代码如下: if(document.getElementById) { alert(document.getElementById);//output: function getElementById(){ [native code] }; } 如上例,该方法判断所在浏览器是否支持getElementById()方法,注意,这里if语句中的检测对象没

代码如下:
if(document.getElementById)
{
alert(document.getElementById);//output: function getElementById(){ [native code] };
}
如上例,该方法判断所在浏览器是否支持getElementById()方法,注意,这里if语句中的检测对象没有括号“()”。
对象特征检测法判断浏览器对javascript对象的支持_javascript技巧
对象特征检测法判断浏览器对javascript对象的支持_javascript技巧: 代码如下: if(document.getElementById) { alert(document.getElementById);//output: function getElementById(){ [native code] }; } 如上例,该方法判断所在浏览器是否支持getElementById()方法,注意,这里if语句中的检测对象没