各种方法判断客户端浏览器是否安装了Flash插件

常用的方法: 

<SCRIPT  LANGUAGE="JavaScript">  

<!--  
var  swf  =  new  ActiveXObject('ShockwaveFlash.ShockwaveFlash');  
(swf)  ?  document.writeln('你已经安装了插件')  :  document.writeln('你没有安装插件');  
//  -->  
</SCRIPT> 

动态加载. 

<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="mFlash" 
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0
WIDTH="120" HEIGHT="60" id="468x60" ALIGN="" VIEWASTEXT> 
<PARAM NAME=quality VALUE=high> 
</OBJECT> 
<input type=button οnclick="addFlash()" value="Add"> 
<input type=button οnclick="mFlash.Stop()" value="Stop"> 
<input type=button οnclick="mFlash.Play()" value="Play"> 
<script> 
function addFlash() { 
mFlash.movie="http://expert.csdn.net/images/ad/WIBU.swf"; 
mFlash.Play(); 

</script> 

有很多检测PLUGIN的方法,因为不能只用一个方法就解决了这个问题,所以才有了这么多的方法 

一、内置的检测 
NN和MAC上的IE不能使用以下的检测,只有WIN上的IE可以 
1、即需即装 
在IE的工具-Internet选项-高级-浏览里面的即需即装选项如果生效了,当浏览器需要,就会从MS的网站下载Flash Player ActiveX control 
如果没生效,你没安装PLUGIN又直接进入了网页,就会看到一个裂开的方块那样的小ICON,点一下也可以带你去安装 
2、HTML里面的OBJECT标签里面的classid 和 codebase属性 
classid是ActiveX control的标识,例如FLASH PLAYER的就是: 
clsid:D27CDB6E-AE6D-11cf-96B8-444553540000 
codebase则是下载插件的地址,例如FLASH4的(如果浏览器检查到version后面的数字低于你已有版本,就不会安装): 
http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0 
这些HTML标签当你在FLASH中PUBLIC或者DW中插入时都会自动加入 
浏览器执行到这些标签就会进行检测了 

二、用SCRIPT来检测 
这种方法是为了摆脱上一种办法的局限,例如DW里面那个叫"Check Plug-in"的behavior 
这种方法在有些不能执行SCRIPT的机器上还是用不了,例如MAC上IE4.5之前版本,WIN31上面的IE。 
还有某些用户是关闭SCRPIT执行的。 

三、用FLASH来检测 
如果用户连SCRPIT都不执行的话,就只能用这招了。这也是MM自己用的方法。 
做一个检测的HTML,里面放一个SWF,里面只有一句GetURL("你真正的页面") 
同时在HTML的<HEAD>里面放<META HTTP-EQUIV="Refresh" CONTENT="10; URL="没有安装FLASH的页面"> 
如果在10秒之内SWF没有把你带到真正的页面,检测的HTML就会把你带到没安装的页面 

四、最后一个办法,让用户自己选择 
这也是最常见的了,很多网站都做一个入口的页面,下面就有安装PLUGIN的小ICON 

<!-- start VBSCRIPT plugin detection--> 
<SCRIPT LANGUAGE=VBScript> 
Private i, x, MM_FlashControlVersion 
On Error Resume Next 
x = null 
MM_FlashControlVersion = 0 
var Flashmode 
FlashMode = False 
For i = 5 To 1 Step -1 
    Set x = CreateObject("ShockwaveFlash.ShockwaveFlash." & i) 
    
    MM_FlashControlInstalled = IsObject(x) 
    
    If MM_FlashControlInstalled Then 
        MM_FlashControlVersion = CStr(i) 
        Exit For 
    End If 
Next 
FlashMode = (MM_FlashControlVersion >= 5) 
If FlashMode = True Then 
document.write "有FLASH的HTML" 
Else 
document.write "无FLASH的HTML" 
End If 
</SCRIPT><!-- end VBSCRIPT PLUGIN DETECTION --> 


<script type="text/javascript" language="JavaScript"> 
<!-- start JS detection 
FlashMode = 0; 
if (navigator.plugins && navigator.plugins.length > 0) 

    if (navigator.plugins["Shockwave Flash"]) 
    { 
        var plugin_version = 0; 
        var words = navigator.plugins["Shockwave Flash"].description.split(" "); 
        for (var i = 0; i < words.length; ++i) 
        { 
            if (isNaN(parseInt(words[i]))) 
            continue; 
            plugin_version = words[i]; 
        } 
        if (plugin_version >= 5) 
        { 
            var plugin = navigator.plugins["Shockwave Flash"]; 
            var numTypes = plugin.length; 
            for (j = 0; j < numTypes; j++) 
            { 
                mimetype = plugin[j]; 
                if (mimetype) 
                { 
                    if (mimetype.enabledPlugin && (mimetype.suffixes.indexOf("swf") != -1)) 
                        FlashMode = 1; 
                    // Mac wierdness 
                    if (navigator.mimeTypes["application/x-shockwave-flash"] == null) 
                        FlashMode = 0; 
                } 
            } 
        } 
    } 

if (FlashMode == 1) 

document.write('有FLASH的HTML');} 
else { 
document.write('无FLASH的HTML'); } 
// end JS detection --> 


通过以下的Javascript脚本,可以检测当前浏览器是否安装Flash插件以及插件的版本是否满足要求。 

<SCRIPT LANGUAGE="JavaScript1.1"> 
<!-- 
// U can change this number to check specific version of flash 
var MM_contentVersion = 6; 

var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? 
navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0; 

if ( plugin ) { 
var words = navigator.plugins["Shockwave Flash"].description.split(" "); 
for (var i = 0; i < words.length; ++i){ 
if (isNaN(parseInt(words[i]))) 
continue; 
var MM_PluginVersion = words[i]; 

var MM_FlashCanPlay = MM_PluginVersion >= MM_contentVersion; 

else if( navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 && 
(navigator.appVersion.indexOf("Win") != -1) ) { 
//FS hide this from IE4.5 Mac by splitting the tag 
document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n'); 
document.write('on error resume next \n'); 
document.write('MM_FlashCanPlay = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & MM_contentVersion)))\n'); 
document.write('</SCR' + 'IPT\> \n'); 


if ( MM_FlashCanPlay ) { 
alert("Flash Detection OK. U can play."); 

else{ 
alert("Flash Detection Failed. Need Download specific version."); 

//--> 

</SCRIPT> 


<script> 

//自己总结的 

//IE中判断是否安装插件 
var swf; 
function IE_Flash() 

    try 
    { 
        var swf=new ActiveXObject("ShockwaveFlash.ShockwaveFlash"); 
        alert("已安装插件"); 
    } 
    catch(e) 
    { 
        alert("没有安装插件"); 
    } 

//FireFox,Chrome中判断是否安装插件 
function FF_or_Chrome_Flash() 

    var swf=navigator.plugins["Shockwave Flash"]; 
    (swf)?alert("已安装插件"):alert("没有安装插件"); 

</script>

转载于:https://www.cnblogs.com/JoinZhang/archive/2010/08/11/1797544.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
1.<html> 2.<body> 3.<% 4. //SysDownloadFlashFashion等于0时就是本地下载 5. if(SysDownloadFlashFashion==0){%> 6. <div id="LoGo" solid #606080;cursor:pointer;" align="center"> 7. <div id="hideMarquee">正在检测插件<br><br></div> 8. <marquee id="marquee" 0px; white-space: nowrap;border:1px solid #606080;' direction="right" scrollamount=20 height='20' width='220'> 9. <div>■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ ■</div> 10. </marquee> 11. </div> 12. <div id="Chrome" 13. <%}else{%> 14. <div id="Chrome"> 15. <%}%> 16. <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" 17. id="uploadfile" width="800" height="435" 18. <%if(SysDownloadFlashFashion==1){%> 19. codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab" 20. <%}else{ %> 21. codebase"plugins"> 22. <% } %> 23. <param name="wmode" value="opaque" /> 24. <param name="movie" value="uploadfile.swf" /> 25. <param name="quality" value="high" /> 26. <param name="bgcolor" value="#869ca7" /> 27. <param name="allowScriptAccess" value="sameDomain" /> 28. <embed src="uploadfile.swf" wmode="opaque" quality="high" bgcolor="#869ca7" 29. width="800" height="435" name="uploadfile" align="middle" id="uploadfile" 30. play="true" 31. loop="false" 32. quality="high" 33. allowScriptAccess="sameDomain" 34. type="application/x-shockwave-flash" 35. <%if(SysDownloadFlashFashion==1){%> 36. pluginspage="http://www.adobe.com/go/getflashplayer" 37. <% }else{%> 38. pluginspage="<%=context%>/plugins/Install_Flash_Player_9_Plugin.exe"> 39. <% } %> 40. </embed> 41. </object> 42. </div> 43.</body> 44.[removed] 45.var tishi=0; 46.function InstallFlash() 47.{ 48. if((brower().isIE) || (brower().isIE7) || (brower().isIE8) && <%=SysDownloadFlashFashion%>==0) 49. { 50. LoGo.onclick=function() 51. { 52. if(tishi==0) 53. { 54. [removed].href="plugins/install_flash_player_10_active_x.exe"; 55. alert(message.uploadfile_js_IE_plugins_downLoad_remind); 56. tishi=-1; 57. } 58. } 59. } 60. if(brower().isFirefox && <%=SysDownloadFlashFashion%>==0) 61. { 62. uploadfile.onclick=function() 63. { 64. if(tishi==0) 65. { 66. [removed].href="plugins/Install_Flash_Player_9_Plugin.exe"; 67. alert(message.uploadfile_js_fireFox_plugins_downLoad_remind); 68. tishi=-1; 69. } 70. } 71. } 72. if(brower().isChrome && <%=SysDownloadFlashFashion%>==0) 73. { 74. Chrome.onmouseover=function() 75. { 76. if(tishi==0) 77. { 78. [removed].href="plugins/Install_Flash_Player_9_Plugin.exe"; 79. alert(message.uploadfile_js_Chrome_plugins_downLoad_remind); 80. tishi=-1; 81. } 82. } 83. } 84.} 85.[removed] 86.[removed] 87.var swf = false; 88.if((brower().isIE) || (brower().isIE7) || (brower().isIE8)) 89.{ 90. try 91. { 92. swf = new ActiveXObject('ShockwaveFlash.ShockwaveFlash');//IE已经安装Flash插件 93. if(swf) 94. { 95. LoGo.style.display="none"; 96. Chrome.style.display="block"; 97. } 98. } 99. catch(e)//没有安装Flash插件 100. { 101. swf = false; 102. marquee.style.display="none"; 103. hideMarquee[removed]=message.uploadfile_js_hideMarquee_remind; 104. hideMarquee.style.cursor="hand"; 105. } 106.} 107.else if((brower().isFirefox) || (brower().isChrome)) 108.{ 109. LoGo.style.display="none"; 110. Chrome.style.display="block"; 111. swf = navigator.plugins["Shockwave Flash"];//FireFox,Chrome 112.} 113.if(!swf) 114.{ 115. InstallFlash(); 116.} 117.[removed] 118.</html>

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值