【问题标题】:How can I use my search bar with google custom search?如何将我的搜索栏与谷歌自定义搜索一起使用?
【发布时间】:2014-11-01 16:14:55
【问题描述】:

这是我的表单 html 代码:

<form action="#" class="searh-holder">
    <input name="se" id="se" type="text" class="search" placeholder="Search.." value="" />
    <button class="search-submit" id="submit_btn"><i class="fa fa-search transition"></i></button>
</form>

这是仅用于结果的 Google 自定义搜索脚本:

<script>
  (function() {
    var cx = '013571851987533538767:dc4iymzquf8';
    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:searchresults-only></gcse:searchresults-only>

我不知道如何让我的搜索栏显示 Google 自定义搜索结果。我怎样才能让他们一起工作?非常感谢。

【问题讨论】:

    标签: javascript html search google-search google-custom-search


    【解决方案1】:

    您可以在该输入中使用jQuery Autocomplete

    在用户按下某个键一段时间后,在 google 中进行搜索,并在自动完成中显示结果。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-18
      • 1970-01-01
      • 1970-01-01
      • 2018-12-13
      • 1970-01-01
      相关资源
      最近更新 更多