// call the google search function search() { var q = getObj("q"); //getobj located in script.js (must load before this is called) var cof = getObj("cof"); var cx = getObj("cx"); location.href = "/SearchResults.aspx?q=" + encodeURIComponent(q.value) + "&cof=" + encodeURIComponent(cof.value) + "&cx=" + encodeURIComponent(cx.value) } // for setting the search term back in the textbox call this function on page load function setSearchTerm() { var q = getObj("q"); var regEx = new RegExp("([^?=&]+)(=([^&]*))?"); var m = regEx.exec(location.search); if (m && m[0] && m[0,3]) q.value = decodeURIComponent(m[0,3]); else q.value = ""; } // to apply a search when enter is pressed function onEnter() { if (event.keyCode == 13) search(); }