AFC Previous
Previous
Welcome
Welcome
Next
Next

Using the AFC Detect applet

Using the AFC Detect applet in your own scripts and web pages is easy.

First, include some JavaScript that asks the applet to check if AFC is installed. Use a script similar to:

<SCRIPT LANGUAGE="JavaScript"> <!-- function detectAFC() { if (document.AFCDetect.doesSupportAFC() == 0) { alert("You don't have AFC installed on your machine."); return 0 } else { alert("AFC is installed on your computer."); return 1 } } document.writeln("<applet code=AFCDetect.class name=AFCDetect width=0 height=0></applet>"); //--> </SCRIPT> The script first loads the applet by writing the applet tag to the document. Once this is loaded, you can call the detectAFC() function to detect AFC. This calls the doesSupportAFC() function in the AFC Detect applet. Based on what that function returns, you can determine whether AFC is on the machine or not. You may want to customize this script, perhaps by sending the user to a different page if AFC is not installed.

Now you need some way to run this script. If you would like it to be run as soon as someone loads the page, put the following tag in the top of your HTML file:

<body onLoad="detectAFC()"> This runs the JavaScript detectAFC() function as soon as the page is loaded.

The AFC Detect applet works by trying to dynamically load an AFC class (UIComponent) and trapping any exceptions that are thrown. If a ClassNotFoundException is caught, AFC is not installed, and the function returns the appropriate value. If the class could be loaded, AFC is installed.

Advanced AFC Detection - Obtaining the current AFC Version

AFC Detect also supports obtaining the current version of AFC and comparing to a given version number. The AFC Detect applet supports the following functions:
  • public String getAFCVersionString()
  • public int getAFCMajorVersion()
  • public int getAFCMinorVersion()
You can call them from JavaScript with a line similar to: iMajorVersionNumber = document.AFCDetect.getAFCMajorVersion() getAFCVersionString() returns the dot-separated major and minor version number. The other functions simply return the integer corresponding to that field. See the source for AFCDetectInfo.htm for more details.


Remarks:
This sample created with Microsoft AFC.

Top © 1996 Microsoft Corporation. All rights reserved.