Chandrashekar Jupalli
Chandrashekar Jupalli

Reputation: 347

URL with special characters not opening

Uri with + symbol is not opening.. for example I have a file in folder !+123@1, want to show it in browser. window.open(url);

Upvotes: 1

Views: 259

Answers (3)

Vojtech B
Vojtech B

Reputation: 2957

You can see how the text translates by using encodeURIComponent or online tool http://meyerweb.com/eric/tools/dencoder/

+ translates to %2B

Upvotes: 0

Oluwafemi
Oluwafemi

Reputation: 14869

The web browser interprets the plus + symbol as space. Use encodeURIComponent to encode it instead.

Upvotes: 1

too_cool
too_cool

Reputation: 1194

Try to use encodeURIComponent

window.open("http://your-url.com/" + encodeURIComponent("foo+123.jpg"));

Upvotes: 3

Related Questions