我使用 Xpages 自定义控件创建了一个搜索字段 (id:searchField) 和一个搜索按钮 (id:searchButton)。我在搜索字段上添加了一个 onkeypress 事件,以便触发对 searchButton 的单击。然后 searchButton 将重新加载页面,但 url 参数来自搜索字段。问题是页面重新加载,但当我在搜索字段中按 ENTER 时搜索参数未添加到 URL ,但当我按 searchButton 时正常工作。以下是我使用的代码:
(添加到searchField的onkeypress的代码)
if (typeof thisEvent == 'undefined' && window.event) { thisEvent = window.event; } 如果(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 的错误还是我在这里遗漏了什么?