admin管理员组

文章数量:1579928

function hasPlugin(name) {
	var userAgent = window.navigator.userAgent	//取得浏览器的userAgent字符串  
    var isIE = userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1	//判断是否IE<11浏览器  
    var isEdge = userAgent.indexOf("Edge") > -1 && !isIE	//判断是否IE的Edge浏览器  
    var isIE11 = userAgent.indexOf('Trident') > -1 && userAgent.indexOf("rv:11.0") > -1;
    // 如果是ie浏览器,通过ActiveXObject判断是否存在插件,需要注意的是,在IE浏览器和非IE浏览器中判断是否存在该插件时,传的参数是不一样的,IE浏览器下,传的参数是COM对象,而在非IE浏览器下,传的参数是字符串
    if(isIE || isEdge || isIE11) {
    	try{
    		new ActiveXObject(name)
    		return true
    	} catch {
    		return false
    	}
    } else {
    	name = name.toLowerCase()
		const plugins = window.navigator.plugins
		for(let i = 0; i < plugins.length; i++){
			if (plugins[i].name.toLowerCase() === name) {
				return true
			}
		}
		return false
    }
}
console.log(hasPlugin('Chrome PDF Plugin'))    // true

 

本文标签: 插件器中安装了