Checks whether the client installs the Silverlight plug-in and determines whether IE is installed or supports Silverlight (ie only)

Source: Internet
Author: User

1. Check whether the client has installed the Silverlight plug-in.
<SCRIPT type = "text/JavaScript">
Function checksilverlightinstalled ()
{
VaR issilverlightinstalled = false;
Try {
Try {
VaR slcontrol = new activexobject ('agcontrol. agcontrol'); // check IE
Issilverlightinstalled = true;
}
Catch (e ){
If (navigator. plugins ["Silverlight plug-in"]) // check for non-ie
{
Issilverlightinstalled = true;
}
}
}
Catch (e ){}
Return issilverlightinstalled;
}
Alert ("is the Silverlight plug-in installed? "+ Checksilverlightinstalled ())
</SCRIPT>
<SCRIPT type = "text/JavaScript">
Function checksilverlightinstalled ()
{
VaR issilverlightinstalled = false;
Try {
Try {
VaR slcontrol = new activexobject ('agcontrol. agcontrol'); // check IE
Issilverlightinstalled = true;
}
Catch (e ){
If (navigator. plugins ["Silverlight plug-in"]) // check for non-ie
{
Issilverlightinstalled = true;
}
}
}
Catch (e ){}
Return issilverlightinstalled;
}
Alert ("is the Silverlight plug-in installed? "+ Checksilverlightinstalled ())
</SCRIPT>

2. js checks whether IE is installed or supports Silverlight! (Only Ie can be detected)

JS checks whether IE is installed or supports Silverlight!
In JS, you can use the try and catch language names to determine whether the client has installed the Silverlight plug-in, and use the isversionsupported method of the plug-in to determine whether the client currently supports the specified version of Silverlight. Program !
View plaincopy to clipboardprint?
<MCE: script language = "JavaScript"> <! --
Function validsilverlight (d)
{
VaR c = false, A = NULL;
Try
{
VaR B = NULL;
VaR v = Window. Navigator. useragent;
If (V. indexof ("MSIE")>-1)
{
B = new activexobject ("agcontrol. agcontrol ");
}
Else if (navigator. plugins ["Silverlight plug-in"])
{
A = Document. createelement ("Div ");
Document. Body. appendchild ();
If (V. indexof ("safari")>-1)
A. innerhtml = '<embed type = "application/X-Silverlight"/> ';
Else A. innerhtml = '<object type = "application/X-Silverlight" Data = "data:,"/> ';
B = A. childnodes [0]
}
// Document. Body. innerhtml;
If (B. isversionsupported (D) c = true;
B = NULL;
} Catch (E)
{
C = false
}
If (a) Document. Body. removechild ();
Return C;
}
Alert (validsilverlight ("1.0 "));
// --> </MCE: SCRIPT>
<MCE: script language = "JavaScript"> <! --
Function validsilverlight (d)
{
VaR c = false, A = NULL;
Try
{
VaR B = NULL;
VaR v = Window. Navigator. useragent;
If (V. indexof ("MSIE")>-1)
{
B = new activexobject ("agcontrol. agcontrol ");
}
Else if (navigator. plugins ["Silverlight plug-in"])
{
A = Document. createelement ("Div ");
Document. Body. appendchild ();
If (V. indexof ("safari")>-1)
A. innerhtml = '<embed type = "application/X-Silverlight"/> ';
Else A. innerhtml = '<object type = "application/X-Silverlight" Data = "data:,"/> ';
B = A. childnodes [0]
}
// Document. Body. innerhtml;
If (B. isversionsupported (D) c = true;
B = NULL;
} Catch (E)
{
C = false
}
If (a) Document. Body. removechild ();
Return C;
}
Alert (validsilverlight ("1.0 "));
// --> </MCE: SCRIPT>
The Silverlight control in ASP. NET uses this check. If you use this control, you can directly use the method "Silverlight. isinstalled (Version)" to call it!

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.