简体   繁体   English

使用<input type ='image'>提交表单,不再在Chrome中使用

[英]Submit form with <input type = 'image'> no longer working in Chrome

The image button: 图像按钮:

<form name='form1' method='post' target='new'>
    <input type='image' src='dismiss.png' name='inputname' value='inputvalue'/>
</form>

In Chrome 69.0.3497.100, var_dump($_POST) looks like this: 在Chrome 69.0.3497.100中,var_dump($ _ POST)如下所示:

array(2) { ["dismiss_x"]=> string(1) "5" ["dismiss_y"]=> string(1) "2" }

In FF and Safari, it looks like this (correct with name and value): 在FF和Safari中,它看起来像这样(正确的名称和值):

array(3) { ["dismiss_x"]=> string(1) "5" ["dismiss_y"]=> string(1) "9" ["inputname"]=> string(10) "inputvalue" } dis

Chrome seems to be sending only the coordinates of the click, not the actual input name or value. Chrome似乎只发送点击的坐标,而不是实际的输入名称或值。

This worked fine in Chrome last week. 这在上周的Chrome中运行良好。

Changing input type to "submit" works fine in Chrome as well. 将输入类型更改为“提交”也可以在Chrome中正常运行。

Chrome spec compliance apparently has changed: Chrome规范合规性显然已发生变化:

https://www.chromestatus.com/feature/5672688152477696 https://www.chromestatus.com/feature/5672688152477696

This accomplishes the exact same thing, and works on all browsers: 这完成了完全相同的事情,适用于所有浏览器:

<form name='form1' method='post' target='new'>
    <button type='submit' name='inputname' value='inputvalue' style='background:none;border:none;padding:0'><img src='dismiss.png'></button>
</form>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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