Initialize Method

 

The Initialize method is the default method of the BrowserHawk ActiveX component. When you the component from ASP by using the Server.CreateObject statement, the Initialize method for the component is automatically called for you. That is why you can simply create an instance of the object and start checking properties, without having to call any methods first.

 

If you using the component from ColdFusion scripts, or embedding it into another software program or component then you will need to call the Initialize method directly. Note: When calling the Initialize method manually like this, the GetExtPropertiesEx method (and any properties which rely on this method being called) are unavailable. As such all properties that require these methods to have their value set will only contain their default values. ColdFusion users should see the cf_examples.zip sample in their BrowserHawk directory for details on how to use these methods through ColdFusion.

 

Syntax:

bhObject.Initialize uaString [, notUsedString]

 

Object: an instance of the BrowserHawk ActiveX component created with the "CreateObject" statement – not "Server.CreateObject".

uaString: the user agent string of the browser you want to retrieve the capabilities for.

notUsedString: this parameter is not longer used or required but provided for backward compatibility. Note however that ColdFusion developers still need to pass in a dummy string to satisfy the CFM engine.

 

Tip: It is common for developers to write scripts that go through log files to extract user agents and create a BrowserHawk object for each log entry using the Initialize method. When doing so, however, care should be taken to remove any special characters or place holders that have been added to the log file by the web server. For example, Internet Information Server places plus signs in all strings to represent spaces (for example: "Mozilla/4.0+(compatible;+MSIE+4.01;+Windows+NT"). To receive accurate results it is important that you remove the plus signs and replace them with spaces before passing the user agent as a parameter in the Initialize method.

 

See Also:

Sample usage from VB WebClasses

Using BrowserHawk in your web scripts