For Client Side JavaScript, the Window object serves as the global object for all JavaScript code contained within the browser window.

This window object is referenced using window property instead of this to refer the global object.

Javascript Global Object:Safe URI-Encoding Methods

JavaScript Global object Method encodeURI() and encodeURIComponent() takes a Uniform Resource Identifier(URI), which contains characters which are not allowed within a URI standard, and then encodes it to fit the standard.

The URI encode method encodes the URI so that it is acceptable to the browser, by replacing all invalid characters with the special UTF-8 encoding .

The Difference is that, encodeURI() works on entire URL, while encodeURIComponent() works solely on a segment of URI (say any illegal values.)

Example: Javascript Global Object: URI Encoding Methods.

Give it a TRY! » Note:encodeURI() replaced only spaces with
%20 while encodeURIComponent() encodes all nonalphanumeric character.

Javascript Global Object : Decode URIs

The counter to above methods are the, decodeURI() and decodeURIComponent() methods are available.