如何在新的_blank窗口中使此URL框搜索机定位?



如何使用URL 字符串使搜索页面的搜索词在单独的_blank窗口中打开?现在它可以工作,但只能作为目标_self,而不是像_blank那样在新窗口中。

我需要这个在空白的新窗口中显示结果。

JavaScript:

<script language="JavaScript">
function GoToURL()
{
var URLis;
URLis = document.URLframe.u.value
{
var location=("https://SearchMyPageA.com/?q=" + URLis + "&ia=meanings");
this.location.href = location;
}
}
</script>

.HTML:

<form name="URLframe" method="post">
<input value="test" type="text" name="u" size="70">
<input type="button" onclick="GoToURL(this)" value=" Search ">
</form>

注意:我宁愿想要一个 JavaScript 答案,但如果对此没有 JavaScript 答案,那么我想查询答案也可以。

COOL 部分:这是此代码的COOL 部分。这适用于互联网上几乎所有的搜索引擎,只需对值和 JavaScript 进行一些调整,以适应我们使用的搜索框的数量。您唯一需要做的就是在原始页面上键入test,然后查看URL在该页面上的外观,然后替换单词URL地址和结尾文本,+ URLis +代表您在搜索框中键入的内容,而不是测试

无法使用位置打开新窗口。尝试改用_blank作为第二个参数window.open()

function GoToURL()
{
var URLis;
URLis = document.URLframe.u.value
{
var location=("https://SearchMyPageA.com/?q=" + URLis + "&ia=meanings");
//this.location.href = location;
window.open(location, '_blank')
}
}
<form name="URLframe" id="form" method="post">
<input value="test" type="text" name="u" size="70">
<input type="button" onclick="GoToURL(this)" value=" Search ">
</form>

尝试使用...

window.open(
'https://SearchMyPageA.com/?q=' + URLis + '&ia=meanings',
'_blank' // <- This is what makes it open in a new window.
);

最新更新