问题描述
我有一个脚本编辑器,可以从另一个网站(不是SharePoint)上查找数据 website
I have a script editor which I can look a data from another website (It s not a SharePointwebsite), here is the code:
<输入id ="GInput" maxlength ="20"形式="/"
<输入id ="GBtn" value ="GO" type ="button"形式="/">
< script type ="文本/javascript">
document.getElementById("GBtn").addEventListener("click",function(){
var value = document.getElementById("GInput").value;
window.location.href =" URL =" +值;
<script type="text/javascript">
document.getElementById("GBtn").addEventListener("click", function(){
var value = document.getElementById("GInput").value;
window.location.href = "URL=" + value;
});
</script>
我想要的是与我在文本框中按下Enter键时所用的语言相同的功能,它与单击搜索按钮时一样.
感谢您的帮助
推荐答案
按下KeyBorad中的Enter键时,我们可以触发按钮单击事件,如下所示:
We can trigger button click event when press Enter key in the KeyBorad like below:
<input id="myInput" value="Some text..">
<button id="myBtn" onclick="javascript:alert('Hello World!')">Button</button>
<script>
var input = document.getElementById("myInput");
input.addEventListener("keyup", function(event) {
event.preventDefault();
if (event.keyCode === 13) {
document.getElementById("myBtn").click();
}
});
</script>
最后,请检查keyCode是否等于13,这是实现它的Enter Key Ascii值.
In conclusion, check if keyCode is equal to 13 which is the Enter Key Ascii value to achieve it.
谢谢
最好的问候
这篇关于脚本Enter键与搜索Button的作用相同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!