当前位置:
尊龙游戏旗舰厅官网 >
前端技术
> javascript
>内容正文
javascript
【js】检测插件 -尊龙游戏旗舰厅官网
为什么80%的码农都做不了架构师?>>>
//plugin detection - doesn't work in ie function hasplugin(name){name = name.tolowercase();for (var i=0; i < navigator.mimetypes.length; i ){if (navigator.mimetypes[i].name.tolowercase().indexof(name) > -1){return true;}}return false; }//detect flash alert(hasplugin("flash"));在ie下不支持netscape式的插件,在ie中检测插件的唯一方式 是使用专有的activexobject类型,并创建一个特定插件的实例,ie是以com对象的方式实现插件的,而com对象使用唯一标识符来标识。所以,在ie下要检测特定插件,必须知道其com标识符。比如flash的标识符是shockwaveflash.shockwaveflash。
//plugin detection for ie function hasieplugin(name){try {new activexobject(name);return true;} catch (ex){return false;} }//detect flash alert(hasieplugin("shockwaveflash.shockwaveflash"));一般针对每个插件分别创建检测函数,而不是使用通用检测方法:(以检测flash插件为例)
//detect flash for all browsers function hasflash(){var result = hasplugin("flash");if (!result){result = hasieplugin("shockwaveflash.shockwaveflash");}return result; }//detect flash alert(hasflash());转载于:https://my.oschina.net/hin911/blog/371281
总结
- 上一篇: 探究platform_driver中“多
- 下一篇: 原型图mockplus:怎样使用图片裁切