gwt 1.6.4 即 8 ff 3.6.13
我的用户希望能够按回车键在 gwt TextBox 中提交表单。所以我写了代码,让它工作然后发现它双重提交(在 firefox 中) 所以我把它拿出来,注意到在 firefox 中按回车键会导致页面提交,但在 IE 中不会。
所以要么我让它工作一半(两个流行的浏览器之一),要么它在 ie 中工作并在 firefox 中双重提交。
建议? 我已经看到很多关于此的评论,但没有针对 gwt 的评论。
最佳答案
input.addKeyPressHandler(new KeyPressHandler()
{
@Override
public void onKeyPress(KeyPressEvent event_)
{
boolean enterPressed = KeyCodes.KEY_ENTER == event_
.getNativeEvent().getKeyCode();
if (enterPressed)
{
//submit logic here
}
}
});
关于forms - 在 Firefox 的 google web toolkit 的 TextBox 中点击 enter 会导致表单提交,但不会导致 IE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5318391/