简体   繁体   English

Internet Explorer:URL中的HTML实体

[英]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&copy=true\"' />";

If I klick on the image, Chrome redirects to index.php?p=1&copy=true . 如果我在图片上滑动,Chrome将重定向到index.php?p=1&copy=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 &amp; 我尝试使用&amp; insted of & , but I got the same problem: IE replaces it into the copyright symbol. 插入了& ,但我遇到了同样的问题:IE将其替换为版权符号。

How can I use &copy in my URL? 如何在URL中使用&copy I know that one possible solution would be to replace &copy with &whatever , but than I must change my hole system. 我知道一种可行的解决方案是将&copy替换为&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&copy=true it should still work with index.php?copy=true&amp;p=1 . 代替index.php?p=1&copy=true它仍然可以与index.php?copy=true&amp;p=1

The correct version is with the &amp; 正确的版本是&amp; . Sadly, though, IE11 does indeed have a Big Old Bug in it causing it to take &amp;copy and turn it into the copyright symbol. 但是,令人遗憾的是,IE11确实确实存在一个旧错误,导致它进行&amp;copy并变成版权符号。

I found a workaround: Percent-encode the c in copy : 我找到了一种解决方法:对copyc进行百分比编码:

echo "<input type='image' src='myImage.png' onClick='location.href = \"index.php?p=1&amp;%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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM