1141Chapter 42 .Global Functions and Statements Accessing an (Web hosting india)

1141Chapter 42 .Global Functions and Statements Accessing an ActiveXObject, especially one on the client, involves some seri ous security considerations. The typical security setup for an IE client prevents scripts from accessing client applications, at least not without asking the user if it s okay to do so. While it s foolhardy to state categorically that you cannot perform surreptitious inspection or damage to a client without the user s knowledge (hack ers find holes from time to time), it is highly unlikely. In a corporate environment, where some level of access to all clients is desirable, the client may be set up to accept instructions to work with ActiveX objects when they come from trusted sources. The bottom line is that unless you are well versed in Windows program ming, don t expect the ActiveXObject to become some kind of magic portal that enables you to invade the privacy or security of unsuspecting users. For more details, visit http://msdn.microsoft.com/scripting/ jscript/doc/jsobjActiveXObject.htm. Dictionary While the Dictionary object is very helpful to VBScript authors, JavaScript already provides the equivalent functionality natively. A Dictionary object behaves very much like a JavaScript array that has string index values (similar to a Java hash table), although numeric index values are also acceptable in the Dictionary. Indexes are called keys in this environment. VBScript arrays do not have this facility natively, so the Dictionaryobject supplements the language for the sake of convenience. Unlike a JavaScript array, however, you must use the vari ous properties and methods of the Dictionary object to add, access, or remove items from it. You create a Dictionary object via ActiveXObjectas follows: var dict = new ActiveXObject( Scripting.Dictionary ) You must create a separate Dictionary object for each array. Table 42-2 lists the properties and methods of the Dictionaryobject. After you create a blank Dictionary object, populate it via the Add() method for each entry. For example, the following statements create a Dictionaryobject to store U.S. state capitals: var stateCaps = new ActiveXObject( Scripting.Dictionary ) stateCaps.Add( Illinois , Springfield ) You can then access an individual item via the Key property (which, thanks to its VBScript heritage, looks more like a JavaScript method). One convenience of the Dictionary object is the Keys() method, which returns an array of all the keys in the dictionary something that a string-indexed JavaScript array could use. Table 42-2 Dictionary Object Properties and Methods Property Description Count Integer number of entries in the dictionary (read-only) Item( key ) Reads or writes a value for an entry whose name is key Key( key ) Assigns a new key name to an entry Continued Dictionary
We would like to recommend you tested and proved virtual web hosting services, which you will surely find to be of great quality.

Leave a Reply