php - 为什么 ismap 属性不尊重查询字符串?

标签 php html

假设我有以下 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/

相关文章:

javascript - 显示阵列中的特定元素?

javascript - 在 HTML 标签中查找特定关键字并使用 jquery 进行替换

html - CSS 优先级规则

jquery - HTML - 字全宽

php - AJAX 调用仅适用于 $(document).on ('click' )

php - 使用外部样式表、脚本、包含等的 Codeigniter 最佳实践

php - 在哪里可以找到有关text()xpath查询语法的一些官方文档?

javascript - 根据mysql表中的值更改行的字体颜色

php - 核心报告 API - 忽略 URL 参数和 "group by"

javascript - 交替背景图像之间的间距