SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

So here's what I've come up with so far. Now I just need to figure out how to use the enter key as well as the mouse click.

<!doctype html>
<html lang="en">


function customSearch(inputId,type,site,scope) { 

var searchUrl = site + '/_layouts/OSSSearchResults.aspx?'; 

<!-- // Or '/_layouts/SearchResults.aspx?' -->

var searchTerm = '&k=' + document.getElementById(inputId).value; 
var listParams = '&cs=This%20' + type + '&u=' + scope; window.location.href = searchUrl + searchTerm + listParams; 


function searchKeyPress(buttonId,e) { 

<!-- // look for window.event in case event isn't passed in -->

if (window.event) { 
e = window.event; 

if (e.keyCode == 13) {
} </script>

<input name="searchBox1" id="searchBox1" onkeypress="searchKeyPress('searchButton1',event);" type="text"/> 

<input name="searchButton1" id="searchButton1" onclick="customSearch( 'searchBox1', 'Site', 'RegEng', 'RegEng' );" type="button" value="Search"/> 

share|improve this question

I believe you try to recreate the search page (the actual search box and search tabs). It is an easier way, and proper too, as described in this article and further under

Basically, the search box is available via the Search Web Parts (it might require to activate the Site collection feature related to "Search Web Parts"), however the Search Tabs a control (SPSWC:ListBoundTabStrip), which is driven by the content in the List - "Tabs in Search Pages" (usually there is another list to also store what Tabs to see on actual Result pages too - "Tabs in Search Results"). The TABS are usually available under Enterprise Search Sites, which actually are also Publishing Sites - driven by a Page Layout (open the search center via SPD 2010).

So instead of using CEWP to attempt to replicate this, rather add the actual "Search Box Web Part" and the Tabs Control - the easiest way is to open the actual Search Page Layout

share|improve this answer
Unfortunately, we're using Foundation 2010 - and I don't have permissions to modify code server-side. I'm just a lowly Site Owner with limited privileges (and skills). – Bill Mar 8 '13 at 21:07
not very lucky with the Search Tabs (it is part of the Server assemblies), however as Site Owner you could still edit pages and add "Search box web part" – Marius Constantinescu - MVP Mar 8 '13 at 21:09
good idea, but we don't have any search web parts available. – Bill Mar 8 '13 at 21:16
that's true, back to square-1 -… – Marius Constantinescu - MVP Mar 8 '13 at 21:21
nice - looks promising. can't say the same about my future. – Bill Mar 8 '13 at 21:25

The search uses the url to pass parameters.

Take a look at the url on your search result page and you will see your 'search query' is in the url. It's fairly easy to make a JavaScript that 'generates' this url and redirects to user to it.

  • create a textbox
  • create a search button with a javascript onclick event
  • in the JavaScript read the textbox value
  • paste this textbox value to the url of the search result page
  • redirect the user to the this new url
share|improve this answer
this sounds great--looking forward to testing this. thanks! – Bill Mar 9 '13 at 20:51

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.