English 中文(简体)
为谷歌自定义搜索框的商业版本提供占位符或值?
原标题:Providing placeholder or value to a commercial version of google custom search box?

我如何能输入一个占位符或值 来支付我的 Google 自定义搜索框的版本?

我试图利用谷歌提供的正常的 API 脚本插件如下:

<h5>SEARCH ON THIS SITE</h5></h6>
<div id="cse-search-form" style="width: 100%;">Loading ...</div>

<script type="text/javascript">
    google.load( search ,  1 , {language :  en });
    google.setOnLoadCallback(function() {
        var customSearchOptions = {};
        var imageSearchOptions = {};
        imageSearchOptions[ layout ] = google.search.ImageSearch.LAYOUT_CLASSIC;
        customSearchOptions[ enableImageSearch ] = true;
        customSearchOptions[ imageSearchOptions ] = imageSearchOptions;  
        var customSearchControl = new google.search.CustomSearchControl(
         312312312313123321312231:9cjokpdtmuaey , customSearchOptions);
        customSearchControl.setResultSetSize(
            google.search.Search.FILTERED_CSE_RESULTSET);
        var options = new google.search.DrawOptions();
        options.enableSearchboxOnly("search.htm");
        customSearchControl.draw( cse-search-form , options);
    }, true);
</script>

我的密码有明显错误吗?

我在的表格上发现了类似的问题, https://stackoverflow.com/ questions/7857154/default-value- in-the-sear-box-of-the-google-custom-search-search/10687999#10687999m>。

问题回答

以下是解决办法:

  <div id="cse-search-form" style="width:100%;"></div>
  <script src="http://www.google.com/jsapi" type="text/javascript"></script>
  <script type="text/javascript">
    google.load( search ,  1 , {language :  en , style : google.loader.themes.SHINY});
    google.setOnLoadCallback(function() {
      var customSearchOptions = {};  var customSearchControl = new google.search.CustomSearchControl(
         XXXXXXXXXXXXXXXXXXXXX:xxxxxxxxxxx , customSearchOptions);
      customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
      var options = new google.search.DrawOptions();
      options.setSearchFormRoot( cse-search-form );
      customSearchControl.draw( cse , options);
      customSearchControl.setSearchCompleteCallback(this,function(){
        jQuery( #main ).hide();
        jQuery( #cse ).show();
        var query = jQuery( input.gsc-input ).val();
        jQuery( #cse:not(.processed) ).prepend( <h1 id="page-title" class="title"><span class="left">Search</span>:<span class="right"></span></h1> ).addClass( processed );
        jQuery( #cse .right ).html(    + query);
      });
        jQuery( input.gsc-input:not(.placeholder) ).val( Search ).addClass( placeholder );
        // Focus on search box block.
        jQuery( input.gsc-input ).bind( focus , function(){
         if (jQuery(this).val() ==  Search ){
        jQuery(this).val(  );
         }
         }).bind( blur , function(){
           if (jQuery(this).val() ===   ){
          jQuery(this).val( Search );
           }
        });
    }, true);
  </script>




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签