检测所有浏览器中安装的Flash Player [英] Detect Flash Player Installed in all Browsers

查看:118
本文介绍了检测所有浏览器中安装的Flash Player的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用javascript检测用户系统中是否安装了flash。



请帮帮我..



我需要在所有浏览器中检测(特别是IE)

I need to detect whether flash is installed in users system using javascript.

Please help me..

I need to detect in all browsers( Especially IE)

推荐答案

大家好,



步骤如下:



步骤1:从下面的链接下载外部JavaScipt。



第2步:在eclipse中创建JSP并导入外部JS。

将外部JS导入Eclipse项目的步骤:

右键单击您的项目 - >新 - > JavaScript源文件 - >点击:高级 - >选择:链接到文件系统中的文件 - >你的Exteranl JS文件夹然后点击完成。



步骤3:复制以下两个Java脚本标签并将其粘贴到你的身体标签内。



步骤4:在onclick或onsubmit中调用check()方法。

示例:< input type =buttonvalue =Submitonclick = check()/>



*************************** ************************************************** ******

上面的代码将不起作用,但代码下面的代码将适用于所有情况,即使Flash插件被禁用。它会提醒您插件被禁用或启用,安装或未安装,并将您重定向到Flash网站以安装Flash播放器。



注意:我的代码需要预定义(外部)JavaScript。这适用于所有浏览器IE,Chrome,Firefox,Safari,Netscape,opera。



您可以使用以下URL并下载预定义(外部)JavaScript:



https:// drive。 google.com/file/d/0BxPiAFM0fZYkZ1p4Yi1hVUUzaWM/view?usp=sharing



############下面的脚本是检测浏览器#############



Hi All,

Steps to follow:

Step 1: Download the External JavaScipt from below link.

Step 2: Create JSP in eclipse and import the external JS.
Steps to import external JS to Eclipse project:
Right Click on your project -> New -> JavaScript Source File -> Click :Advanced -> Select :Link to File in Filesystem -> your Exteranl JS folder and click to finish.

Step 3: Copy the below two Java scripts tags and paste it inside your body tag.

Step 4: Call the check() method in your onclick or onsubmit.
example : <input type="button" value="Submit" onclick="check()" />

***********************************************************************************
The above piece of code will not function but below code will work on all scenarios even the Flash plugin is disabled. It will alert you plugin is disabled or enabled, installed or not installed and redirect you to flash site to install the flash player.

NOTE : My code need a predefined(external) JavaScript. This will work on all the browsers IE,Chrome,Firefox,safari,Netscape,opera.

you may use the below URL and download the predefined(external) JavaScript:

https://drive.google.com/file/d/0BxPiAFM0fZYkZ1p4Yi1hVUUzaWM/view?usp=sharing

############Below script is to detect the browser#############

<SCRIPT LANGUAGE="javascript">
function browserName(){
    var nAgt = navigator.userAgent;
    var browserName  = navigator.appName;
    var fullVersion  = ''+parseFloat(navigator.appVersion);
    var majorVersion = parseInt(navigator.appVersion,10);
    var nameOffset,verOffset,ix;

    // In Opera, the true version is after "Opera" or after "Version"
    if (verOffset=!!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0)
    {
            browserName = "Opera";
            fullVersion = nAgt.substring(verOffset+6);
            if ((verOffset=nAgt.indexOf("Version"))!=-1)
                fullVersion = nAgt.substring(verOffset+8);
    }

    // In MSIE, the true version is after "MSIE" in userAgent
    else if ((verOffset=nAgt.indexOf("MSIE"))!=-1)
    {
            browserName = "Microsoft Internet Explorer";
            fullVersion = nAgt.substring(verOffset+5);
    }

    // In Chrome, the true version is after "Chrome"
    else if ((verOffset=nAgt.indexOf("Chrome"))!=-1)
    {
            browserName = "Chrome";
            fullVersion = nAgt.substring(verOffset+7);
    }

    // In Safari, the true version is after "Safari" or after "Version"
    else if ((verOffset=nAgt.indexOf("Safari"))!=-1)
    {
            browserName = "Safari";
            fullVersion = nAgt.substring(verOffset+7);
            if ((verOffset=nAgt.indexOf("Version"))!=-1)
                fullVersion = nAgt.substring(verOffset+8);
    }

    // In Firefox, the true version is after "Firefox"
    else if ((verOffset=nAgt.indexOf("Firefox"))!=-1)
    {
            browserName = "Firefox";
            fullVersion = nAgt.substring(verOffset+8);
    }

    // In most other browsers, "name/version" is at the end of userAgent
    else if ( (nameOffset=nAgt.lastIndexOf(' ')+1) < (verOffset=nAgt.lastIndexOf('/')) )
    {
            browserName = nAgt.substring(nameOffset,verOffset);
            fullVersion = nAgt.substring(verOffset+1);
            if (browserName.toLowerCase()==browserName.toUpperCase())
        {
                browserName = navigator.appName;
        }
    }

    // trim the fullVersion string at semicolon/space if present
    if ((ix=fullVersion.indexOf(";"))!=-1)
            fullVersion=fullVersion.substring(0,ix);
    if ((ix=fullVersion.indexOf(" "))!=-1)
            fullVersion=fullVersion.substring(0,ix);

    majorVersion = parseInt(''+fullVersion,10);

    if (isNaN(majorVersion))
    {
            fullVersion  = ''+parseFloat(navigator.appVersion);
            majorVersion = parseInt(navigator.appVersion,10);
    }

    return browserName.substring(0, 6).toLowerCase();
}
</SCRIPT>









< b> *********下面的代码检测到flash播放器是(已安装或未安装)和(已启用或已禁用)*********



< script type =text / javascriptsrc =PluginDetect.js>< / script>

< script type =text / javascript>

功能检查()

{



if(browserName()==chrome)

{

PluginDetect.getVersion(。);

var version = PluginDetect.getVersion('Flash',true);

if(version == null)

{



window.alert(抱歉,Flash Player未安装或未安装启用。);

}

else

{

var maxversion = parseInt(version.substring(0 ,1));



if(maxversion< = 0)

{

window.alert(抱歉,Flash Player未安装或未启用。);

window.location =https:// get。 adobe.com/flashplayer/;

}



}

}

else

{

PluginDetect.getVersion(。);

var version = PluginDetect.getVersion('Flash',true);



if(version == null)

{



窗口。 alert(抱歉,Flash Player未安装或未启用。);

window.location =https://get.adobe.com/flashplayer/;

}

其他

{



var maxversion = parseInt(version.substring(0,1) ));

if(maxversion< = 0)

{

window.alert(你没有flash播放器); < br $> b $ b window.location =https://get.adobe.com/flashplayer/;

}

}

}





}

< / script >

******************* END ******************** *******





*********below code detect the flash player is (installed or not installed) and (Enabled or disabled)*********

<script type="text/javascript" src="PluginDetect.js"></script>
<script type="text/javascript">
function check()
{

if(browserName()=="chrome")
{
PluginDetect.getVersion(".");
var version = PluginDetect.getVersion('Flash', true);
if(version==null)
{

window.alert("Sorry, Flash Player is either not installed or not enabled.");
}
else
{
var maxversion = parseInt(version.substring(0, 1));

if(maxversion<=0)
{
window.alert("Sorry, Flash Player is not installed or not enabled.");
window.location="https://get.adobe.com/flashplayer/";
}

}
}
else
{
PluginDetect.getVersion(".");
var version = PluginDetect.getVersion('Flash', true);

if(version==null)
{

window.alert("Sorry, Flash Player is either not installed or not enabled.");
window.location="https://get.adobe.com/flashplayer/";
}
else
{

var maxversion = parseInt(version.substring(0, 1));
if(maxversion<=0)
{
window.alert("you dont have a flash player");
window.location="https://get.adobe.com/flashplayer/";
}
}
}


}
</script>
******************* END ***************************


您好先查看此链接..



< a href =https://code.google.com/p/swfobject/> SWFObject



hi first check this link..

SWFObject

var hasFlash = false;
try {
  var fo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash');
  if(fo) hasFlash = true;
}catch(e){
  if(navigator.mimeTypes ["application/x-shockwave-flash"] != undefined) hasFlash = true;
}


这篇关于检测所有浏览器中安装的Flash Player的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆