我想根据我输入的输入文本按 Enter 键转到 p2.htm 或 p3.htm。我还想按 Submit1 按钮手动提醒('no1')。
它在 FireFox 中工作,但在 IE6 中,当我按 Enter 键时,它将提交提交按钮。
我怎样才能在 IE 6 中像在 FireFox 中一样做到这一点?
我使用 JavaScript 和 jQuery。
<input id="Text2" type="text" onkeyup="if(event.keyCode==13){go2();}" />
<input id="Text3" type="text" onkeyup="if(event.keyCode==13){go3();}" />
<input id="submit1" type="submit" value="submit" onclick="alert('no1')" />
<script type="text/javascript">
function go2()
{
window.location = "p2.htm";
}
function go3()
{
window.location = "p3.htm";
}
</script>
如果使用 MVC3,您可以通过编辑 BeginForm 调用来禁用通过 Enter 提交,如下所示:
@using (Html.BeginForm("SomeAction", "SomeController", FormMethod.Post, new { onkeydown = "return event.keyCode!=13" }))
{
...
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)