0

これを使用してGoogle CSEを埋め込んでいます:

google.load('search', '1', {language : 'en', style : google.loader.themes.SHINY});
google.setOnLoadCallback(function() {
var options = {};
options[google.search.Search.RESTRICT_EXTENDED_ARGS] = {'sort': 'date'};
var customSearchControl = new google.search.CustomSearchControl('',options);
customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
customSearchControl.draw('cse');

ユーザーが検索する検索用語を特定/表示したいのですが、ユーザーが「検索」をクリックした後、Google CSE 入力から検索用語を取得できないようです。

これどうやってするの?

4

2 に答える 2

2

これはそれを取得する必要があります:

var customSearchControl = new google.search.CustomSearchControl('your key');
customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);

// add this    
customSearchControl.setSearchStartingCallback(this,
        function(sc, searcher, query) {
            alert(query);
            // or do whatever you want with it here.
        }
);
于 2011-05-13T16:59:21.937 に答える
0

返されるヘッダーで検索用語を使用できるようにすべきではありません。実際の ajax リクエストにアクセスできず、jquery を使用してヘッダー オブジェクトにアクセスできないのではないかと考えています。Googleで通常の検索を行うと、キーワードがヘッダーに渡されることを知っています。

于 2010-12-14T15:12:48.820 に答える