Michael Kiselev Michael Kiselev - 1 year ago 89
Javascript Question

Convert ascii character codes into letters in a string containing text and ascii codes in JS

I am working on an HTML web page, and in the js, I read the end of the URL and place it in a div e.g. if the URL is

http://example.com/file.html?postval=Hello, world!

it should post "Hello, world!", unfortunately, it posts "Hello,%20world". how can I fix this?

Answer Source

Use decodeURIComponent

var a = decodeURIComponent('Hello,%20world');

a = 'Hello, world!';
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download