2012-11-14 20 views
0

我正在嘗試使用ajax調用進行自定義Google搜索。使用ajax調用的自定義Google搜索

我在谷歌搜索,發現一個good link

這裏有一個文本框和一個按鈕自動出現,當我們點擊搜索按鈕時,結果顯示在div中。

但我想搜索寫在我自己創建的文本框中的項目。手段:手動我創建了一個文本框和一個按鈕。我想用我的文本框中的查詢點擊我的按鈕時顯示結果。

請幫忙

在此先感謝。

回答

2

寫這篇文章提交按鈕

// get a custom search control & keep it in cseControl 
// note: put your own custom search ID number here 
var cseControl = new google.search.CustomSearchControl('009827885688477640989:igzwimalyta'); 
// open pages from search results clicks on the same page 
cseControl.setLinkTarget(google.search.Search.LINK_TARGET_SELF); 
// when there are no matches, explain why 
cseControl.setNoResultsString("Sorry, there are no pages in this web site that match all the search terms."); 
// make the search field visible in div with ID 'cseDiv' 
cseControl.draw('divGoogleResult'); 

cseControl.execute(userInput); 
$('.gsc-search-box').hide(); 
相關問題