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:
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:
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.
|