谷歌自定义搜索框结果显示在同一页面或选项卡上不在不同页面或选项卡上

时间:2013-10-10 11:01:36

标签: javascript php

这是我正在开发的网站的链接

http://ashteldemo.com/leonardpatel/

我在页面右上角使用了谷歌自定义搜索框

当任何人写入查询并点击输入时,它应该在不同的页面或不同的选项卡中显示结果,但它在同一页面或相同的选项卡上显示结果

这是由google提供的代码:

<script>
(function() {
var cx = '006011017794504203273:7s66ki24jds';
var gcse = document.createElement('script');
gcse.type = 'text/javascript';
gcse.async = true;
gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
    '//www.google.com/cse/cse.js?cx=' + cx;
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(gcse, s);
})();
</script>
<gcse:searchbox-only></gcse:searchbox-only>

什么可以解决这个问题?,我想在不同的标签上显示搜索结果或

1 个答案:

答案 0 :(得分:2)

您可以尝试使用HTML插入Google搜索表单,然后在提交按钮上设置目标。

例如,

<form id="cse-search-box" action="http://google.com/cse">
<input type="hidden" name="cx" value="YOUR SEARCH ENGINE ID goes here" />
<input type="hidden" name="ie" value="UTF-8" />
<input type="text" name="q" size="31" />
<input type="submit" name="sa" target="_blank" value="Search" />
</form>
<img src="http://www.google.com/cse/images/google_custom_search_smwide.gif">

https://support.google.com/customsearch/answer/1351747?hl=en