我的Google自定义搜索无法加载。 我在Chrome控制台中遇到的JS错误是:
Uncaught TypeError: Object [object Object] has no method 'enableSearchBoxOnly'
我的代码:
<div class="search">
<div id='cse-search-form' style='width: 100%;'>Loading</div>
</div>
<script src='//www.google.com/jsapi' type='text/javascript'></script>
<script type='text/javascript'>
google.load('search', '1', {language: 'es', style: google.loader.themes.DEFAULT});
google.setOnLoadCallback(function() {
var customSearchOptions = {};
var customSearchControl = new google.search.CustomSearchControl('003806993800906102968:1a2oqwxzgqk', customSearchOptions);
customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
var options = new google.search.DrawOptions();
options.enableSearchBoxOnly('https://www.globalsign.es/buscar', 'q');
customSearchControl.draw('cse-search-form', options);
}, true);
</script>
提前感谢您的帮助!
答案 0 :(得分:2)
API Reference表示enableSearchBoxOnly
错误大写。尝试
options.enableSearchboxOnly('https://www.globalsign.es/buscar', 'q');
而不是用大写字母b开始“盒子”。
options.enableSearchBoxOnly('https://www.globalsign.es/buscar', 'q');
^