相关疑难解决方法(0)

XPages - onkeypress事件未正确触发点击

我使用Xpages自定义控件创建了一个搜索字段(id:searchField)和一个搜索按钮(id:searchButton).我在搜索字段上添加了一个onkeypress事件,这样它就会触发对searchButton的点击.然后,searchButton将重新加载页面,但url参数来自搜索字段.问题是页面重新加载但是当我在搜索字段中按Enter时搜索参数没有添加到URL ,但是当我按下searchButton时工作正常.以下是我使用的代码:

(代码添加到searchField的onkeypress)

if (typeof thisEvent == 'undefined' && window.event) { thisEvent = window.event; }
if (thisEvent.keyCode == 13)
{
    document.getElementById("#{id:searchButton}").click();
}

(代码添加到searchButton的onclick)

window.location.href = "test.xsp?search=" + document.getElementById("#{id:searchField}").value;

我在IE和Firefox中测试过它们都有问题.我创建了一个示例HTML文件,它工作正常.这是XPages的错误还是我错过了什么?

javascript onclick javascript-events onkeypress xpages

5
推荐指数
2
解决办法
4336
查看次数