这里似乎关键的是我在本地磁盘上打开HTML(即它不是由Web服务器提供的.)
<html> <head> <Meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <title>website</title> </head> <body> <a href="%C3%A9.html">Fails on IE - works everywhere else (Firefox,Chrome,Safari)</a> <p /> <a href="é.html">Works on IE</a> </html>
谢谢
克雷格
解决方法
Non US-ASCII Characters
Characters outside of US-ASCII may appear in Windows file paths and accordingly they’re allowed in file IRIs. (URIs are defined as US-ASCII only and so when including non-US-ASCII characters in a string,what you’ve actually created is called an IRI: Internationalized Resource Identifier.) Don’t use percent-encoded octets to represent non US-ASCII characters because,in file URIs,percent-encoded octets are interpreted as a byte in the user’s current codepage. The meaning of a URI containing percent-encoded octets for bytes outside of US-ASCII will change depending on the locale in which the document is viewed. Instead,to represent a non-US-ASCII character you should use that character directly in the encoding of the document in which you are writing the IRI. For instance:
Incorrect: file:///C:/example%E3%84%93.txt
Correct: file:///C:/exampleㄓ.txt
换句话说,由于您的HTML使用的是UTF-8,因此URL必须使用非百分号编码的UTF-8八位字节作为é字符,这就是é.html工作和é.html失败的原因 – 没有名为Ã的文件例如,©.html.
这就是Internet Explorer的工作方式.这不是一个bug.其他浏览器只是做了不同的事情,就是这样.除非您可以将Web服务器配置为向IE提供与其他浏览器不同的HTML,否则您将不得不使用客户端技术,例如条件注释,例如:
<html> <head> <Meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <Meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9"> <title>website</title> </head> <body> <!--[if IE]> <a href="é.html">Works on IE</a> <![endif]--> <!--[if !IE]> --> <a href="%C3%A9.html">Works everywhere else</a> <!-- <![endif]--> </html>
需要X-UA兼容元标记,因为Microsoft removed support for HTML conditional comments in IE 10实现了对HTML5的支持.