The JavaScript escape() method takes any string or expression and returns a string in which all non-alphanumerical characters are converted to their numeric equivalent in the form %XX. The XX is a hexadecimal number representing the non-alphanumerical character.

For example, space is replaced with %20 and the & sign is replaced with %26.

However, according to this article,  the escape method will not encode: @*/+

To encode some of these characters, use the encodeURI() method.

However, to complicate matters further, the encodeURI() method will not encode the following characters: , / ? : @ & = + $ #.

Use the encodeURIComponent() method to encode these characters.

I created a test page that allows you test the behavior of these methods.