问题
I need to put a link with this href="file://attachments/aaaa_#_aaaa.msg"
Obviously in that way is not working because the hash character #
is used for anchors.
So I try to change this to: href="file://attachments/aaaa_%23_aaaa.msg"
but when I open the url in the IE, the browser is trying to open this: href="file://attachments/aaaa_%2523_aaaa.msg"
IE is encoding the %
character to %25
How can I put the file name in the URL to encode and read the hash character #
in all the browsers to download the file?
I can't change the file name to remove this character, so I need a way to deal with this problem.
回答1:
You will avoid lots and lots and lots of pain if you are able to rename your files so they don't contain a "#" character. As long as they do, you will probably have current and future cross-browser issues, confusion on behalf of future developers working on your code (or confusion on your behalf in the future, when you've forgotten the ins and outs of the encoding), etc. Also, some Unix/Linux systems don't allow "#" in filenames. Not sure what OS you're using, but your filenames should be as portable as possible across OSs, even if you're "sure" right now that you'll never be running on one of those systems.
来源:https://stackoverflow.com/questions/21526313/use-character-in-url-inside-file-name