如何在新页面中显示自定义Google搜索结果

时间:2009-12-31 04:31:57

标签: javascript html xml

我在网页上使用自定义Google搜索

代码:

<div id="cse" style="width: 100%;">Loading</div>
<script src="http://www.google.com/jsapi" type="text/javascript"></script>
<script type="text/javascript">
  google.load('search', '1', {language : 'en'});
  google.setOnLoadCallback(function(){
    var customSearchControl = new google.search.CustomSearchControl('016457557644291857915:ivjbplcmt5k');
    customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
    customSearchControl.draw('cse');
  }, true);
</script>

上面的代码工作正常,但它在该页面本身显示搜索结果。我想在单独的页面中显示搜索结果页面。

需要代码帮助

2 个答案:

答案 0 :(得分:3)

您可以使用Custom Search API中的特殊方法,只需在setResultSetSize()之后和draw()方法之前添加此行:

customSearchControl.setLinkTarget(google.search.Search.LINK_TARGET_BLANK)

链接将在新窗口中打开。

我希望这应该按你的意愿运作。

答案 1 :(得分:0)

在“外观和感觉”标签中使用 iframe 选项怎么样?

  

iframe。提供有限的自定义功能,需要单独进行   您网站上的搜索结果页面。