Ben Nadel
On User Experience (UX) Design, JavaScript, ColdFusion, Node.js, Life, and Love.
Ben Nadel at CFUNITED 2010 (Landsdown, VA) with: Elliott Sprehn and Debbie Flax
Ben Nadel at CFUNITED 2010 (Landsdown, VA) with: Elliott Sprehn@ElliottZ ) and Debbie Flax

JavaScript encodeURIComponent() Escapes "+" Symbol

By Ben Nadel on

I just blogged about how I was going to have to manually escape the "+" symbol when passing values from my AJAX web page to my ColdFusion back end, but I just happened upon a Javascript method that I have never seen before:


According to, this method was introduced in Javascript 1.5. Here is a small description from the site:

Lastly, the encodeURIComponent() method should be used in most cases when encoding a single component of a URI. This method will encode certain chars that would normally be recognized as special chars for URIs so that many components may be included. Note that this method does not encode the ' character, as it is a valid character within URIs.

This seems to do the trick. Sweet-ass find!

Looking For A New Job?

Ooops, there are no jobs. Post one now for only $29 and own this real estate!

100% of job board revenue is donated to Kiva. Loans that change livesFind out more »

Reader Comments

Just used this to pass JSON through the URL. Dumped URL scope on the receiving page and get something looking like this:

  • {"street_number":32,"viewport":"","administrative_area_level_1":"Auckland","country_short":"NZ","route":"Vialou Ln"}

Wondering how to work with this data, i.e. if there's an easy way to parse the separate variables out into useable format without a lot of list functions and suchlike.