我有谷歌网站的搜索
http://www.google.com/cse/manage/create
这给了我以下工作代码:
<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('013080392637799242034:ichqh_hal4w');
customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
customSearchControl.draw('cse');
}, true);
</script>在我的一些页面上,我有一个搜索框。我可以让文本输入在那个搜索框,张贴到这个网站的搜索脚本和加载?
例如:
中重新键入文本。
现在我有:
// Temporary measure
SearchBox.click(function (event) {
SearchBox.attr('disabled', 'disabled');
SearchBox.css("background", "#efefef");
window.location.replace(Domainroot + "/search");
});虽然不太理想,但效果很好。当用户单击“搜索”框时,它会将其重定向到搜索页,以将输入查询的用户双倍保存。
谢谢你的帮助!
发布于 2011-06-25 23:35:56
看看http://code.google.com/apis/customsearch/docs/js/cselement-reference.html#_methods-el
看起来,您创建的控件是带有方法的。您似乎在寻找.execute(查询)方法。
发布于 2011-06-25 17:44:19
一种方法是将iFrame代码直接放在您的主页上,然后您可以自定义它。你会找到各种各样的方法来做这件事。但是,如果你想要一个更个性化的东西,比如有一个搜索框,然后在你的页面中有结果,那么我建议你做一个后端过程来查询谷歌,然后把结果发回。看看Nokogiri的例子,我的意思是。
https://stackoverflow.com/questions/6478496
复制相似问题