Google CSE在新窗口中打开 [英] Google CSE open in new window

查看:137
本文介绍了Google CSE在新窗口中打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将Google搜索栏集成到我的网站中,并使用Google CSE的默认代码:

 < div id =cse-search-formstyle =width:100%;>正在载入< / div> 
< script src =https://www.google.com/jsapitype =text / javascript>< / script>
< script type =text / javascript>
google.load('search','1',{language:'en'});
google.setOnLoadCallback(function(){
var customSearchOptions = {};

var imageSearchOptions = {};
imageSearchOptions ['layout'] = google.search .ImageSearch.LAYOUT_POPUP;
customSearchOptions ['enableImageSearch'] = true;
customSearchOptions ['imageSearchOptions'] = imageSearchOptions;

var customSearchControl = new google.search.CustomSearchControl(
'003243520079760326318:WMX-1462312306',customSearchOptions);

customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
var options = new google.search.DrawOptions() ;
options.setSearchFormRoot('cse-search-form');
options.setAutoComplete(true);
customSearchControl.draw('shop.htm / cse',options);
},true);






随后样式和< / div>



但我不希望结果在同一页面上打开,我希望它们在具有容器div的searchresults.htm中打开

 < div id =csestyle =宽度:100%;>< / DIV> 

如果我放入这个表格:

 < form action =http://www.amberantiques.com/searchresults.htmid =cse-search-box> 
< fieldset style =border:none;>
< input type =hiddenname =cxvalue =003243520079760326318:WMX-1462312306/>
< input type =hiddenname =ievalue =UTF-8/>
< input type =textname =qsize =31/>
< input type =submitname =savalue =Search/>
< / fieldset>
< / form>

然后表单将它发送到页面,但不运行搜索,但是如果您使用Google酒吧在页面上,它运行搜索罚款。

基本上,你如何获得google bar打开结果页面?



干杯

解决方案

当您为Google CSE构建代码时,其中一个外观选项为双页 - 这将允许您在一个页面上搜索,并在另一个页面上显示结果。


I would like to integrate the Google Search bar into my site, and using the default code by Google CSE I have:

        <div id="cse-search-form" style="width: 100%;">Loading</div>
<script src="https://www.google.com/jsapi" type="text/javascript"></script>
<script type="text/javascript"> 
  google.load('search', '1', {language : 'en'});
  google.setOnLoadCallback(function() {
    var customSearchOptions = {};

    var imageSearchOptions = {};
    imageSearchOptions['layout'] = google.search.ImageSearch.LAYOUT_POPUP;
    customSearchOptions['enableImageSearch'] = true;
    customSearchOptions['imageSearchOptions'] = imageSearchOptions;

    var customSearchControl = new google.search.CustomSearchControl(
      '003243520079760326318:WMX-1462312306', customSearchOptions);

    customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
    var options = new google.search.DrawOptions();
    options.setSearchFormRoot('cse-search-form');
    options.setAutoComplete(true);
    customSearchControl.draw('shop.htm/cse', options);
  }, true);

Followed by the style and the </div>

But I do not want the results to open on the same page, I want them to open in searchresults.htm which has the container div

<div id="cse" style="width:100%;"></div> 

if I put in this form:

<form action="http://www.amberantiques.com/searchresults.htm" id="cse-search-box">
    <fieldset style="border:none;">
        <input type="hidden" name="cx" value="003243520079760326318:WMX-1462312306" />
        <input type="hidden" name="ie" value="UTF-8" />
        <input type="text" name="q" size="31" />
        <input type="submit" name="sa" value="Search" />
    </fieldset>
</form>

Then the form sends it to the page but doesnt run the search, but if you then use the Google bar on the page, it runs the search fine.

Basically, how do you get the google bar to open the results page?

Cheers

解决方案

When you're building the code for your Google CSE, one of the Look and Feel options is "Two Page" - which will allow you to search on one page, and display the results on another.

这篇关于Google CSE在新窗口中打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆