In-Page Search Option
The JavaScript Source: Navigation : In-Page Search Option
Simply click inside the window below, use your cursor to highlight the script, and copy [Control]+C the script into a new file in your text editor (such as Note Pad) and save [Control+S]. The script is yours!!!
<!– Paste this code into an external JavaScript file named: search.js –>
/* This script and many more are available free online at
The JavaScript Source :: http://javascript.internet.com
Created by: Ivan Iraola :: http://www.cybexmag.com */
function DoSearch() {
var Flag = 0;
if (document.ToolBox.SearchOption[0].checked==true) {
var Flag = 1;
var Engine = document.ToolBox.SearchOption[0].value;
var Query = document.ToolBox.SearchBox.value;
var locName = “http://www.google.com/search?hl=en&q=”;
if (Query == “”) {
alert(“Please enter a search term”);
return;
}
location.href = (locName + Query)
}
if (document.ToolBox.SearchOption[1].checked==true) {
var Flag = 1;
var Engine = document.ToolBox.SearchOption[1].value;
var Query = document.ToolBox.SearchBox.value;
var locName = “http://search.yahoo.com/search?p=”;
if (Query == “”) {
alert(“Please enter a search term”);
return;
}
location.href = (locName + Query)
}
if (document.ToolBox.SearchOption[2].checked==true) {
var Flag = 1;
var Engine = document.ToolBox.SearchOption[2].value;
var Query = document.ToolBox.SearchBox.value;
if (Query == “”) {
alert(“Please enter a search term”);
return;
}
var searchPage = “<HTML>”;
searchPage += “\n”;
searchPage += “<FRAMESET ROWS=\”50%,50%\”>”;
searchPage += “\n”;
searchPage += “<FRAME SRC=\”http://www.google.com/search?hl=en&q=” + Query + “\”>”;
searchPage += “\n”;
searchPage += “<FRAME SRC=\”http://search.yahoo.com/search?p=” + Query + “\”>”;
searchPage += “\n”;
searchPage += “</FRAMESET>”;
searchPage += “\n”;
searchPage += “</HTML>”;
document.write(searchPage);
}
if (Flag == 0) {
alert(“Please select a search engine”);
}
}
<!– Paste this code into the HEAD section of your HTML document.
You may need to change the path of the file. –>
<script type=”text/javascript” src=”search.js”></script>
<!– Paste this code into the BODY section of your HTML document –>
<form name=”ToolBox” style=”line-height: 2em;”>
Enter search term(s): <input type=”text” name=”SearchBox” size=”22″>
<br>
<input type=”radio” name=”SearchOption” value=”Google”>Google
<input type=”radio” name=”SearchOption” value=”Yahoo”>Yahoo
<input type=”radio” name=”SearchOption” value=”Both”>Both
<button type=”button” onclick=”DoSearch()”>Search</button>
</form>
<p><div align=”center”>
<font face=”arial, helvetica” size”-2″>Free JavaScripts provided<br>
by <a href=”http://javascriptsource.com”>The JavaScript Source</a></font>
</div><p>
Comments
