Javascript 点击IE6上的enter键提交按钮名称
我只在IE6上有问题 我有一个包含多个表单的页面,每个表单都包含一个文本框和一个提交按钮。当我使用.NETMVC时,我需要提交按钮的名称来执行正确的操作。当我按下“回车”键时,我的行为与Firefox或Chrome上的点击行为相同(字段和按钮名被发送),但在IE6中没有,在IE6中,我只有发送的字段 那么,当我在IE6上按“回车”键时,如何发送按钮的名称呢 tl/dr: 我要寄这封信Javascript 点击IE6上的enter键提交按钮名称,javascript,html,internet-explorer-6,Javascript,Html,Internet Explorer 6,我只在IE6上有问题 我有一个包含多个表单的页面,每个表单都包含一个文本框和一个提交按钮。当我使用.NETMVC时,我需要提交按钮的名称来执行正确的操作。当我按下“回车”键时,我的行为与Firefox或Chrome上的点击行为相同(字段和按钮名被发送),但在IE6中没有,在IE6中,我只有发送的字段 那么,当我在IE6上按“回车”键时,如何发送按钮的名称呢 tl/dr: 我要寄这封信 Field=foo&Search= 通过单击IE6上的“回车”键 Field=foo Chrome和
Field=foo&Search=
通过单击IE6上的“回车”键
Field=foo
Chrome和Firefox通过点击或点击“回车”功能运行良好
谢谢你的帮助:)
[编辑]添加一个示例:
源代码
<!-- gestion type operation -->
<fieldset>
<legend>Interface de gestion des Types d'Opérations</legend>
<% Html.BeginForm("TypeOperation", "Administration", FormMethod.Post); %>
<%= Html.EditorFor(m => m.TypeOperationField)%>
<input type="submit" id="RechercheTypeOperation" name="RechercheTypeOperation" value=""
class="loupe" />
<% Html.RenderPartial("ListeTypeOperation", Model); %>
<% Html.EndForm(); %>
</fieldset>
<!-- gestion type operation -->
操作类型的接口消化
m、 TypeOperationField)%%>
这很简单,每次我在页面中需要搜索文本框+提交按钮时,都会重复这个表单结构。
生成代码时,表单可以很好地打开和关闭
生成代码
<!-- gestion type operation -->
<fieldset>
<legend>Interface de gestion des Types d'Opérations</legend>
<form action="/Administration/TypeOperation" id="form3"
method="post">
<input class="text-box single-line" id="TypeOperationField"
name="TypeOperationField" type="text" value="" />
<input type="submit" id="RechercheTypeOperation"
name="RechercheTypeOperation" value="" class="loupe" />
<div>
<table class="grid">
<thead>
<tr>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
</tr>
</tbody>
</table>
</div>
</form>
<script type="text/javascript">//
<![CDATA[
if (!window.mvcClientValidationMetadata) { window.mvcClientValidationMetadata = []; }
window.mvcClientValidationMetadata.push({"Fields":[],"FormId":"form3","ReplaceValidationSummary":false});
//]]>
</script>
</fieldset>
<!-- gestion type operation -->
d'Op和#233型接口设计;配给
//
[编辑2]我已将这一行添加到我的表单中
<!--[if IE]><input type="text" style="display: none;" name="RechercheTypeOperation" value="" disabled="disabled" size="1" /><![endif]-->
它正在工作。我认为,你不应该依赖提交按钮的名称,而应该创建一个
请发布你当前的代码。请停止支持IE6(除非你的老板要求你这样做,并且不想理解IE6需要尽快消亡)。显然,我没有选择使用IE6:'(不,很抱歉,当我使用MVC和属性[AcceptButton(“RechercheTypeOperation”)]来验证我的操作时,我会这样做。好的,很抱歉。我真的不知道MVC中的任何东西,但作为一个糟糕的解决方法,当您在用户代理字符串中看到IE6时,您可能会添加隐藏输入。我已经添加了这一行,它正在工作!谢谢:)您还可以尝试将此输入的类型从text
更改为hidden
,这样您就不需要display:none
CSS。