How would you link to a file that contains a space? Is it possible? I have a javascript document and already have dozens of images that contain spaces but I was hoping to be able to still link to them.
Asked
Active
Viewed 41 times
0
-
Can you give an example of what you're talking about and any code that you have written that fails to do what you ask? This will likely get closed very quickly if you don't do that. – Jay Blanchard May 16 '14 at 13:48
-
The same way you link to a file that does not contain a space. What's the problem here? What have you tried? What happened when you tried it? – gen_Eric May 16 '14 at 13:49
1 Answers
1
%20
is the escaped value for a blank space. Use that in a hyperlink, and you'll get the file you want :)
In case you test it in a browser: modern browsers (Chrome for sure) does not visually change the space to %20
anymore in the address bar, but it does still escape all characters before making a web request.
Edit
Generally speaking, you'd like to html encode your strings via an accessible method, rather than manually escaping the needed characters.
The following SO question has a very elegant solution. If you use it with an element that is not visible to the user (or not even part of the DOM, as is the case with the linked answer), they won't even know.
-
2
-
Did not know about the `+`. But now you mention it, I remember seeing it in the past. – Flater May 16 '14 at 13:52