| The code is as follows |
Copy Code |
| <script language= ' VBScript ' > function Detectunitywebplayeractivex On Error Resume Next Dim Tcontrol, Res, UA, RE, matches, major res = 0 Set Tcontrol = CreateObject ("Unitywebplayer.unitywebplayer.1") If IsObject (Tcontrol) Then If tcontrol.getpluginversion () = "2.5.0f5" Then ' 2.5.0f5 on Vista and later has a auto-update issue ' On Internet Explorer. Detect Vista (6.0 or later) ' And in ', treat it as not installed ' UA = Navigator.useragent Set re = new REGEXP Re. Pattern = "Windows NT (d+)." Set matches = Re. Execute (UA) If matches. Count = 1 Then Major = CInt (Matches (0). Submatches (0)) If major < 6 then res = 1 End If End If Else res = 1 End If End If Detectunitywebplayeractivex = Res End Function </script> <script language= "javascript1.1" type= "Text/javascript" > function Detectunitywebplayer () { var tinstalled = false; if (Navigator.appVersion.indexOf ("MSIE")!=-1 && Navigator.appVersion.toLowerCase (). IndexOf ("Win")!=-1) { tinstalled = Detectunitywebplayeractivex (); } else if (navigator.mimetypes && navigator.mimetypes["application/vnd.unity"]) { if (navigator.mimetypes["application/vnd.unity"].enabledplugin && Navigator.plugins && navigator.plugins["Unity Player"] { Tinstalled = true; } } return tinstalled; } </script> |
Detection code:
| The code is as follows |
Copy Code |
if (Detectunitywebplayer ()) {//New check unity is installed added by Shanmao 2014–3-29 Alert (' Test detection has been installed 111′ ') }else{ SetTimeout ("Check_unity_down ()", 1000); Alert (' Test detection does not have 222′ installed ') } |
Another:
Automatically install Unity Webplayer code: Unityobject.enableautoinstall (TRUE);