JavaScript detects if Unity Webplayer is installed

Source: Internet
Author: User
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);

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.