Determine whether the browser has ActiveX Control installed

Source: Internet
Author: User

In JavaScript, The activexobject object is enabled and the reference of the automation object is returned. Usage:

Newobj = new activexobject (servername. typename [, location]) The activexobject object syntax includes these parts: newobj is a required parameter. Variable name to be assigned to activexobject. Servername is required. Provide the name of the application of the object. Typename is required. The type or class of the object to be created. Location is optional. Name of the network server where the object is created. The Automation server provides at least one type of objects. For example, a word processing application may provide application objects, document objects, and toolbar objects. For example, to create an Excel application and sheet object, the Code is as follows: var excelapp = new activexobject ("Excel. application ");
VaR excelsheet = new activexobject ("Excel. Sheet ")

Once an object is created, it can be referenced in the code using the defined object variable. Next we will look at the reference to the object and method through an example, access the attributes and methods of the new object through the object variable excelsheet and other Excel objects, including the Application Object and activesheet. cells set. The Code is as follows:

1 excelsheet. application. Visible = true;
2 excelsheet. activesheet. cells (1, 1). value = "this is column A, Row 1 ";
3 excelsheet. saveas ("C: \ test. xls ");
4 excelsheet. application. Quit (); we can use it to determine whether the browser has installed the corresponding ActiveX Control: function detectactivex ()
{
Try
{
VaR comactivex = new activexobject ("Control name ");
}
Catch (E)
{
Return false;
}
Return true;
} What is "Control name? When you write a COM component, there is a corresponding clsid. Open your registry (the control has been installed in your system), search for it in hkey_classess_root, and enter the CLSID corresponding to the control, the registration information of the corresponding control will be found in a directory named CLSID under this directory, open this node, one of which is progid, the corresponding value is the name used to create the control;

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.