问题描述
我们正在使用专有的文档查看器,这种查看器在某些Chrome浏览器中使用Pepper版本的Flash并不太好,所以我希望能够检测到并重定向到不同的内容格式。
由于这个版本似乎落后于NPAPI,我一直在使用查找版本号,但这需要每天更新。我宁愿不看UserAgent,因为它是造成麻烦,而不是浏览器的Flash架构,但有什么办法用JavaScript做到这一点?
解决方案我认为应该这样做: var isPPAPI = false;
var type ='application / x-shockwave-flash';
var mimeTypes = navigator.mimeTypes; (mimeTypes&& mimeTypes [type]&& mimeTypes [type] .enabledPlugin&&
mimeTypes [type] .enabledPlugin.filename =='pepflashplayer。
。 dll')isPPAPI = true;
。
UPD№1:不确定是否需要,但我写了一个小小的解释:如果我们的浏览器有一个MIME类型的枚举,我们可以得到一个与指定类型关联的插件。所以我们得到一个与'application / x-shockwave-flash'
相关联的插件,并检查它的文件名是否是'pepflashplayer.dll' code>。我认为这个名字是不变的,将来也不会改变。
UPD 2: 要在Google Chrome中启用/禁用PPAPI,您应该转到以下页面: (对不起,这个网址需要直接粘贴到地址栏中。) UPD№3: 我做了一些调查,发现一个有趣的,帮助我实施跨平台的解决方案。我认为这个代码应该适用于所有操作系统: 查看更新 。 UPD№4: 略微改变了代码以符合今天的现实。现在条件如下所示: 查看。 We are using a proprietary document viewer which doesn't play terribly nice with the Pepper version of Flash found in some flavors of Chrome, so I'd like to be able to detect it and redirect to the same content in a different format. Since this version seems to lag behind the NPAPI one, I have been using FlashDetect to look for the version number but this requires daily updating. I'd rather not look at the UserAgent since it's the flash architecture causing the trouble and not the browser, but is there any method of doing this with Javascript? I think it should be done this way: Demo on jsFiddle. UPD №1: Not sure if needed, but I wrote a little explanation: If our browser has a MIME types enumeration, we can get a plugin associated with a specified type. So we're getting plugin which associated with UPD №2: To enable/disable PPAPI in Google Chrome, you should go to this page: (Sorry, this URL needs to be pasted directly into the address bar.) UPD №3: I did some investigation and found an interesting article that helped me to implement a cross-platform solution. I think that this code should work on all OS: Check out an updated fiddle. UPD №4: Slightly changed the code to meet today's realities. Now condition looks like this: Check out . 这篇关于用Javascript检测辣椒(PPAPI)Flash的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
chrome:// plugins / $ c $
var isPPAPI = false;
var type ='application / x-shockwave-flash';
var mimeTypes = navigator.mimeTypes;
var endsWith = function(str,suffix){
return str.indexOf(suffix,str.length - suffix.length)!== -1; (mimeTypes&& mimeTypes [type]&& mimeTypes [type] .enabledPlugin&&
(mimeTypes [type] .enabledPlugin。 filename ==pepflashplayer.dll||
mimeTypes [type] .enabledPlugin.filename ==libpepflashplayer.so||
endsWith(mimeTypes [type] .enabledPlugin.filename,Chrome.plugin )))isPPAPI = true;
if(mimeTypes&& mimeTypes [type]&& mimeTypes [type]。 enabledPlugin&&
(mimeTypes [type] .enabledPlugin.filename.match(/ pepflashplayer | Pepper / gi)))isPPAPI = true;
var isPPAPI = false;
var type = 'application/x-shockwave-flash';
var mimeTypes = navigator.mimeTypes;
if (mimeTypes && mimeTypes[type] && mimeTypes[type].enabledPlugin &&
mimeTypes[type].enabledPlugin.filename == 'pepflashplayer.dll') isPPAPI = true;
'application/x-shockwave-flash'
and check if its filename is 'pepflashplayer.dll'
. I think that this name is constant and will not be changed in future.chrome://plugins/
var isPPAPI = false;
var type = 'application/x-shockwave-flash';
var mimeTypes = navigator.mimeTypes;
var endsWith = function(str, suffix) {
return str.indexOf(suffix, str.length - suffix.length) !== -1;
}
if (mimeTypes && mimeTypes[type] && mimeTypes[type].enabledPlugin &&
(mimeTypes[type].enabledPlugin.filename == "pepflashplayer.dll" ||
mimeTypes[type].enabledPlugin.filename == "libpepflashplayer.so" ||
endsWith(mimeTypes[type].enabledPlugin.filename, "Chrome.plugin"))) isPPAPI = true;
if (mimeTypes && mimeTypes[type] && mimeTypes[type].enabledPlugin &&
(mimeTypes[type].enabledPlugin.filename.match(/pepflashplayer|Pepper/gi))) isPPAPI = true;