tags:

views:

48

answers:

4

How can I decode a URL using jQuery? My url is

http%3A%2F%2Fdtzhqpwfdzscm.cloudfront.net%2F4ca06373624db.jpg

+3  A: 

Try the decodeURIComponent function:

var decodedUri = decodeURIComponent('http%3A%2F%2Fdtzhqpwfdzscm.cloudfront.net%2F4ca06373624db.jpg');
alert(decodedUri);
Darin Dimitrov
But that doesn't use jQuery (and please don't link to W3Schools, they are good at SEO and poor at teaching correct information)!
David Dorward
@David, so isn't using the `decodeURIComponent` function a correct approach?
Darin Dimitrov
It should be the correct approach, but the W3School link really should go. Nick linked to a MDC article, which should be better
Yi Jiang
@Darin — Tongue in cheek, the question specified jQuery. I'm serious about W3Schools though.
David Dorward
+1  A: 
decodeURIComponent('http%3A%2F%2Fdtzhqpwfdzscm.cloudfront.net%2F4ca06373624db.jpg')
reko_t
+1  A: 

Use decodeURIComponent(), for example:

decodeURIComponent("http%3A%2F%2Fdtzhqpwfdzscm.cloudfront.net%2F4ca06373624db.jpg")

It's not jQuery specific, this is a base JavaScript function.

Nick Craver
+1  A: 

Hi,

You can simply call the standard javascript functions for encoding and decoding respectively.

encodeURIComponent
decodeURIComponent

Enjoy!

Doug