gpt4 book ai didi

asp.net - Internet Explorer 中是否存在输入类型为 ="image"的错误

转载 作者:行者123 更新时间:2023-12-02 00:33:26 27 4
gpt4 key购买 nike

我目前正在使用 IE9 (rtm),我想知道这是我自己的问题还是 Internet Explorer 9 中的错误。

我正在使用 ASP.NET MVC,表单 Controller 定义为:

[HttpPost()]  
[UrlRoute(Path = "Checkout/Cart")]
public ActionResult Cart(ShoppingCartModel cart, string submitButton)

所有浏览器都会导致此方法在回发时被命中。输入类型详细为:

<input type="image" src="/resources/images/removeselected.png" class="rightButton removeSelected" alt="Remove Selected" name="submitButton" value="<%= Html.Encode(Model.REMOVE_SELECTED) %>" />

这是用表单发回的内容:

Chrome: CartId=241&submitButton.x=83&submitButton.y=12&submitButton=removeSelected&Items%5B0%5D.Selected=true&Items%5B0%5D.Selected=false&Items%5B0%5D.OrderItemId=76&Items%5B0%5D.Product.ID=9611&Items%5B0%5D.Quantity=1

Internet Explorer 9: CartId=244&Items%5B0%5D.Selected=true&Items%5B0%5D.Selected=false&Items%5B0%5D.OrderItemId=77&Items%5B0%5D.Product.ID=10091&Items%5B0%5D.Quantity=1&submitButton.x=27&submitButton.y=8

如您所见,Chrome 正在放入 submitButton=removeSelected 而 IE 则没有。它在 Firefox 中也能正常工作。

如果我将其更改为 <input type="submit"> 它可以正常工作。但是,我想使用图像类型

最佳答案

根据specification :

When a pointing device is used to click on the image, the form is submitted and the click coordinates passed to the server. The x value is measured in pixels from the left of the image, and the y value in pixels from the top of the image. The submitted data includes name.x=x-value and name.y=y-value where "name" is the value of the name attribute, and x-value and y-value are the x and y coordinate values, respectively.

您不能期待更多。 IE 不发送 submitButton=removeSelected,是的,但是根据规范没有任何义务这样做。所以你不应该依赖这个参数。其他浏览器发送它的事实可能只是一个实现细节(当然你不应该依赖它)。

解决方法是使用普通提交按钮并尝试使用 CSS 设置样式。

关于asp.net - Internet Explorer 中是否存在输入类型为 ="image"的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5716260/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com