CoalesceIdeas

How to Use Javascript to Detect ActiveX Controls in HTML Pages

ActiveX controls are Microsoft Windows objects used to add advanced capabilities to a web browser or a Windows application such as Outlook or Access. ActiveX controls are not supported by Chrome or Firefox, but internal company web applications can force users to use Internet Explorer, which supports ActiveX interaction with a user’s desktop.

Before you call ActiveX control functions, you must detect the ActiveX control on the system. This is accomplished using Javascript in an HTML or ASP web page. Before calling an ActiveX control, the user must install an ActiveX control and enable it on the Windows system.

How to Manually Install an ActiveX Control

Most developers enable ActiveX controls in the installation wizard. However, some developers simply let you download an OCX file. Before you can run an ActiveX control, the OCX file must be installed. Use the following steps to manually install an ActiveX control on your desktop or server:

  1. Click the Windows “Start” Orb. Type “cmd” into menu text box and press “Enter.”
  2. Type “regsvr32 ocx_file” and press “Enter.” Replace “ocx_file” with the full path and name of your ActiveX control

Verify and Detect an ActiveX Control in Javascript

It’s typical to detect the ActiveX control installation when the user loads the page in the browser. Therefore, the code is not set in a Javascript function. You then display text on the page warning the user that some page functions won’t execute properly without the ability to run the ActiveX control on the page. You then place a link on the page to download the ActiveX control. This Javascript code is how you avoid errors on your HTML pages. The following code detects an ActiveX control:

var activeX = new ActiveXObject("AcroPDF.PDF ");

if (activex == null)

document.write (“The ActiveX object is NOT installed.”);

}

In this example, the Javascript detects Adobe Acrobat reader. If the “activeX’ variable is null, then the object is not installed or it is disabled. This code sends an alert text to the web page, but you can also use a div to display the alert to the user. If the user does not have the ActiveX control installed, use your Javascript code to enable a button to download the software from the developer’s official website.

This code is typically placed at the beginning of the web page in the Javscript “script” tags. It is a quick and easy way to avoid errors on your web pages, and the frustration of users who are unable to get the advanced functions on your pages to work properly.

Exit mobile version