对象特征检测法判断浏览器对javascript对象的支持

(编辑:jimmy 日期: 2026/1/19 浏览:2)

复制代码 代码如下:
if(document.getElementById)
{
alert(document.getElementById);//output: function getElementById(){ [native code] };
}

如上例,该方法判断所在浏览器是否支持getElementById()方法,注意,这里if语句中的检测对象没有括号“()”。