开发者

Mac OS X check if flash is installed

开发者 https://www.devze.com 2023-04-09 04:41 出处:网络
My Mac OS X application opens a webpage via a WebView that requires flash.If the user does not have flash installed I would like to give them a popup telling them to please install flash.

My Mac OS X application opens a webpage via a WebView that requires flash. If the user does not have flash installed I would like to give them a popup telling them to please install flash.

Is there a way to check the webview if the flash plugin is installed? In WebPreferences you can enable/disable PlugIns but I can't find a way to query the 开发者_C百科currently install/enabled ones.

Thanks for any help.


You may be able to write some JavaScript that does the checks and execute it through the WebView's window object. To do this you'll need to read up on JavaScript's navigator object, specifically navigator.plugins.


  1. You can check the installed Flash version via a shell command: /usr/libexec/PlistBuddy -c 'Print CFBundleVersion' /Library/Internet\ Plug-Ins/Flash\ Player.plugin/Contents/Info.plist

  2. Apple has provided JavaScript code to detect plugins on a variety of browsers. If you include this file, the following can be used redirect either to the Flash site or to your popup: detectFlash("http://www.site.com/flashcontent","http://www.site.com/noflash")

  3. Per @Brian Kyle's excellent suggestion, it is possible to check for Flash in navigator.plugins:

var pluginCount = navigator.plugins.length;
for(var i = 0; i < pluginCount; i++){
  if(navigator.plugins[i].name=="Shockwave Flash") {
    document.write("Flash version " + navigator.plugins[i].version);
    break;
  };
};
0

精彩评论

暂无评论...
验证码 换一张
取 消