Using Google Search Appliance on Your SharePoint Site

Adding a Google search to a web page is pretty simple. Just drop in the search form code. Something like this:

<form id=”search-form” method=”get” action=http://search.yoursitehere.com/search>
        <input type=”text” name=”q” size=”25″ maxlength=”255″ value=”"/>
        <input type=”submit” id=”search-submit” name=”btnG” value=”Search”/>
        <input type=”hidden” name=”site” value=”default_collection”/>
        <input type=”hidden” name=”client” value=”default_frontend”/>
        <input type=”hidden” name=”proxystylesheet” value=”default_frontend”/>
        <input type=”hidden” name=”output” value=”xml_no_dtd”/>
</form>

The fact that the search code is in a form tag is a problem. Basically the entire body of your SharePoint page is in an ASP .NET form and you cannot have nested form tags as the inner <form> will not be processed. Some have tested ways of nesting form tags but it is pretty messy and not consistent across browsers.

I found this post that addressed the issue and his code was a great starting place. In fact it worked great on my virtual machine but was giving me issues on the production site. The problem turned out to be the code that was specifying the background image for the search box. A white background was preferred anyway so the code was simplified a bit to the following:

<div>
    <input id=”q” type=”text” size=”25″ style=”border: solid 1px #999999″ onkeydown=”searchkeydown();” />
    <button onclick=”googlesearch();return false;”>Search</button>
</div>
<script type=”text/javascript”>
     searchkeydown = function() {
         if (window.event) {
             key = window.event.keyCode;     //IE
         }
         else {
            key = e.which;     //firefox
         }
         if (key == 13) {
            event.returnValue = false;
             event.cancel = true;
             googlesearch();
         }
     }
    googlesearch = function() {
    window.location=’http://search.yoursitehere.com/search?q=’ + escape(document.getElementById(‘q’).value);
      }
</script>

That should get your Google Appliance (CSE) working in your SharePoint site.

Related Posts

SharePointDesignerSQLDataForm.png SharePointDesignerSQLDataForm_thumb.png SharePointDesignerDataViewSQL.png

SharePoint-InfoPath 2007 Video Tutorial: Displaying SQL Data in Data View Web Parts (Part 2)

image.png image_thumb.png image.png image_thumb.png image.png image_thumb.png InfoPathSQLVideoTutorial.png SharePointDesignerSQLDataForm.png SharePointDesignerSQLDataForm_thumb.png SharePointDesignerDataViewSQL.png

SharePoint-InfoPath 2007 Video Tutorial: Storing InfoPath form data in SQL (Part 1)

image.png image_thumb.png image.png image_thumb.png

Use Multiple Selection Columns in Calculated Fields

MOSSHelpPlay.png

InfoPath Form with Multiple, Dynamic Approvers

Leave a Reply