Web site hosting - 1130 Part IV . JavaScript Core Language Reference

1130 Part IV . JavaScript Core Language Reference string to its encoded version, use the escape() method. This function returns a string consisting of the encoded version. For example: var theCode = escape( Hello there ) // result: Hello%20there Most, but not all, nonalphanumeric characters are converted to escaped ver sions with the escape() function. One exception is the plus sign, which URLs use to separate components of search strings. If you must encode the plus symbol, too, then add the optional second parameter to the function to make the plus symbol convert to its hexadecimal equivalent (2B): var a = escape( Adding 2+2 ) // result: Adding%202+2 var a = escape( Adding 2+2 ,1) // result: Adding%202%2B2 To convert an escaped string back into plain language, use the unescape()func tion. This function returns a string and converts all URL-encoded strings includ ing those encoded with the optional parameter. The escape() function operates in a way that is approximately midway between the newer functions encodeURI()and encodeComponentURI(). The escape() function is best used on portions of URIs, such as the search string. If your scripts bounce back and forth between escaped and unescaped strings, be sure to balance the functions of the same type; use unescape() only on URI strings that are encoded via the escape() function. Finally, be aware of slightly different behavior with regard to the @ symbol in various browsers. This character is not encoded in IE, but it is encoded (to %40) in NN. eval( string ) Returns: Object reference. NN2 NN3 NN4 NN6 IE3/J1 IE3/J2 IE4 IE5 IE5.5 Compatibility . . . Expression evaluation, as you probably are well aware by now, is an important concept to grasp in scripting with JavaScript (and programming in general). An expression evaluates to some value. But occasionally you need to force an additional evaluation on an expression to receive the desired results. The eval() function acts on a string value to force an evaluation of that string expression. Perhaps the most common application of the eval()function is to convert a string version of an object reference to a genuine object reference. For example, one technique for creating a Dynamic HTML script that accommodates the different ways that IE and NN4 reference positionable objects is to assemble references out of the comparable pieces of references. In the following function, the name of a positionable object is passed as a parameter. This example assumes that global eval()
Looking for affordable and reliable webhost to host and run your business application? Then look no more and go to servlet web hosting services.

Leave a Reply