[英]Internet Explorer: HTML entities in URL
I have got the following PHP code: 我有以下PHP代码:
echo "<input type='image' src='myImage.png' onClick='javascript:location.href = \"index.php?p=1©=true\"' />";
If I klick on the image, Chrome redirects to index.php?p=1©=true
. 如果我在图片上滑动,Chrome将重定向到
index.php?p=1©=true
。 But if I klick on the image in Internet Explorer 11, it redirects to index.php?p=1©=true
. 但是,如果我在Internet Explorer 11中单击图像,它将重定向到
index.php?p=1©=true
。
Internet Explorer seems to replace HTML entities in URLs. Internet Explorer似乎替换了URL中的HTML实体。
I tried using &
我尝试使用
&
insted of &
, but I got the same problem: IE replaces it into the copyright symbol. 插入了
&
,但我遇到了同样的问题:IE将其替换为版权符号。
How can I use ©
in my URL? 如何在URL中使用
©
? I know that one possible solution would be to replace ©
with &whatever
, but than I must change my hole system. 我知道一种可行的解决方案是将
©
替换为&whatever
,但是我必须更改孔系统。
There are also other people with the same problem: 也有其他人有相同的问题:
https://gist.github.com/pguillory/5136408 https://gist.github.com/pguillory/5136408
Why not just swap the variables? 为什么不交换变量呢?
Instead of index.php?p=1©=true
it should still work with index.php?copy=true&p=1
. 代替
index.php?p=1©=true
它仍然可以与index.php?copy=true&p=1
。
The correct version is with the &
正确的版本是
&
. 。 Sadly, though, IE11 does indeed have a Big Old Bug in it causing it to take
&copy
and turn it into the copyright symbol. 但是,令人遗憾的是,IE11确实确实存在一个旧错误,导致它进行
&copy
并变成版权符号。
I found a workaround: Percent-encode the c
in copy
: 我找到了一种解决方法:对
copy
的c
进行百分比编码:
echo "<input type='image' src='myImage.png' onClick='location.href = \"index.php?p=1&%63opy=true\"' />";
// --------------------------------------------------------------------------------------^^^
Example of the correct version that nevertheless fails on IE11: http://jsbin.com/dajihiwiwo/ 仍在IE11上失败的正确版本的示例: http : //jsbin.com/dajihiwiwo/
Example of the above (which is also correct, just more obtuse) which works on IE11: http://jsbin.com/nehuxazeka/ 适用于IE11的上述示例(也是正确的,只是更钝): http : //jsbin.com/nehuxazeka/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.