假设我有以下 HTML:
<a href="crocodile.php?name=alex">
<img src="alex.png" ismap>
</a>
我希望浏览器打开类似 crocodile.php?name=alex&41,18
的内容。实际上,打开的 URI 是 crocodile.php?name=alex?41,18
,据我所知,这甚至不能使它成为有效的 URI。例如,在 PHP 中,我以 $_GET['name']
的值 alex?41,18
结束。
这种行为背后有什么原因吗?我希望浏览器能够根据 href
中现有的查询字符串解析 map ,而不是无脑地附加 ?x,y
。
已在 Google Chrome、Firefox 和 Safari 上测试。
最佳答案
这是一个有效的 URL。这就是规范所说的应该发生的事情。 ?41,18
是一个超链接后缀,不是新参数。参见 HTML 5.3 spec - The A element , 步骤 3.2
If the target of the click event is an img element with an ismap attribute specified, then server-side image map processing must be performed, as follows:
If the click event was a real pointing-device-triggered click event on the img element, then let x be the distance in CSS pixels from the left edge of the image to the location of the click, and let y be the distance in CSS pixels from the top edge of the image to the location of the click. Otherwise, let x and y be zero.
Let hyperlink suffix be a U+003F QUESTION MARK character, the value of x expressed as a base-ten integer using ASCII digits, a U+002C COMMA character (,), and the value of y expressed as a base-ten integer using ASCII digits.
关于php - 为什么 ismap 属性不尊重查询字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47454388/