Jquery 当包含值时,如何在window.open中使用_self?

Jquery 当包含值时,如何在window.open中使用_self?,jquery,self,window.open,Jquery,Self,Window.open,它正在工作,但会打开另一个选项卡。如果没有+$(“#input”).val(),它就无法工作 尝试了window.location和所有其他示例,因此。。。 请帮助您能试试这个吗: $("#input").keypress(function(event) { if (event.keyCode == 13) { window.open("search.html?search=" + $("#input").val()); // here is the lo

它正在工作,但会打开另一个选项卡。如果没有+$(“#input”).val(),它就无法工作

尝试了window.location和所有其他示例,因此。。。
请帮助

您能试试这个吗:

$("#input").keypress(function(event) {
        if (event.keyCode == 13) {
            window.open("search.html?search=" + $("#input").val()); // here is the location
            let searchString = $("#input").val()
            localStorage.setItem("search", JSON.stringify(searchString)); 
        }
    });

$(文档).ready(函数(){
$(“#输入”)。按键(功能(事件){
如果(event.keyCode==13){
window.location=“search.html?search=“+$(“#输入”).val();//这是位置
设searchString=$(“#输入”).val()
setItem(“search”,JSON.stringify(searchString));
}
});
});
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
 $("#input").keypress(function(event) {
        if (event.keyCode == 13) {
            window.location = "search.html?search=" + $("#input").val(); // here is the location
            let searchString = $("#input").val()
            localStorage.setItem("search", JSON.stringify(searchString)); 
        }
    });
});
</script>
</head>
<body>

<input id="input"/>
</body>
</html>