【发布时间】:2015-04-19 11:49:38
【问题描述】:
我使用谷歌的自定义搜索引擎在我的网站中添加了一个搜索引擎。我选择了两页布局,因为我想要的是搜索框将在主页上,其结果将显示在另一个页面中。但这对我不起作用。每当我尝试搜索某些内容时,它都不会显示结果,也不会转到页面。我能做些什么?请帮我。谢谢。
搜索框
<script>
(function() {
var cx = 'XXXXXXXX:XXXXXXX';
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>
结果
<script>
(function() {
var cx = 'XXXXXXXX:XXXXXXX';
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>
【问题讨论】:
标签: javascript html search-engine google-custom-search