您需要一个Google自定义搜索引擎用以下代码替换您的搜索表单:
<form action="http://your.blog.url/index.php?s=" id="cse-search-box" class="searchform">
<input type="hidden" name="cx" value="your_CSE_ID" />
<input type="hidden" name="cof" value="FORID:10" />
<input type="hidden" name="ie" value="UTF-8" />
<label for="q">Search</label>
<input type="hidden" name="s" id="s" value="" />
<input type="text" name="q" id="q" class="keyword" />
</form>
<script>
jQuery(\'#q\').bind(\'change\', function() {
jQuery(this).val(function(i, val) {
jQuery(\'#s\').val(val);
return val;
});
});
</script>
<script type="text/javascript" src="http://www.google.com/cse/brand?form=cse-search-box&lang=de"></script>
将此代码用于搜索结果(显示内部结果后):
<div id="cse-search-results"></div>
<script type="text/javascript">
var googleSearchIframeName = "cse-search-results";
var googleSearchFormName = "cse-search-box";
var googleSearchFrameWidth = 600;
var googleSearchDomain = "www.google.com";
var googleSearchPath = "/cse";
</script>
<script type="text/javascript" src="http://www.google.com/afsonline/show_afs_search.js"></script>