SUBSCRIBE VIA RSS


Subscribe to our feed

Symfony Experts

Symfony Experts
If you have an urgent question for a symfony-related issue, this is the place to ask.

Topics

Stack Overflow


The old fashioned way

RECENT TUNES

May 14, 2007 – 2:14am javascript urlencode

In doing a google search for javascript urlencode, I realized I was using that terminology just because I was familiar with the PHP function of the same name. Javascript’s method is actually called encodeURI() which will encode all characters except:

, / ? : @ & = + $ #

But what I really wanted to do was get javascript to convert a string that would be okay to put into a query string of a URL. For this, use encodeURIComponent(). This will convert all characters except alphabetic, decimal digits, and:

- _ . ! ~ * ' ( )

That’s more like it. You can view the complete reference at mozilla or w3schools.

Posted by in  Web Development   |  

5 Responses to javascript urlencode

  1. Alex says:

    This information was indeed useful. Thanks.

  2. Floydan says:

    Thank god someone remembered what that method was called 😀 been looking for ages =)

  3. Michel says:

    Thanks! There are tons of website wrong about this…
    At last I found your post that is right ! 😉

  4. Scott Meves says:

    Glad you found this useful!

  5. Pingback: UrlEncode in Javascript? Call me encodeURI « ?????