Home >Web Front-end >JS Tutorial >Determine whether flash player and current version of JS code are installed_javascript skills

Determine whether flash player and current version of JS code are installed_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:26:121040browse
复制代码 代码如下:

function flashChecker() {
var hasFlash = 0;     //是否安装了flash
var flashVersion = 0;   //flash版本
if(document.all) {
var swf = new ActiveXObject('ShockwaveFlash.ShockwaveFlash');
if(swf) {
hasFlash = 1;
VSwf = swf.GetVariable("$version");
flashVersion = parseInt(VSwf.split(" ")[1].split(",")[0]);
}
} else {
if(navigator.plugins && navigator.plugins.length > 0) {
var swf = navigator.plugins["Shockwave Flash"];
if(swf) {
hasFlash = 1;
var words = swf.description.split(" ");
for(var i = 0; i < words.length; i) {
if(isNaN(parseInt(words[i]))) continue;
flashVersion = parseInt(words[i]);
}
}
}
}
return {
f: hasFlash,
v: flashVersion
};
}

var fls = flashChecker();
var s = "";
if(fls.f) document.write("您安装了flash,当前flash版本为: " fls.v ".x");
else document.write("您没有安装flash");
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn