»
EnglishFrenchVietnamese

Print - In-Page Search Option - JavaScriptBank.com

Full version: jsB@nk » Utility » Search-code » In-Page Search Option
URL: https://www.javascriptbank.com/in-page-search-option.html

In-Page Search Option © JavaScriptBank.comAdd a Google/Yahoo search option to your Web pages. Using radio buttons, you can search each engine individually or both at the same time.

Full version: jsB@nk » Utility » Search-code » In-Page Search Option
URL: https://www.javascriptbank.com/in-page-search-option.html



JavaScript
<script type=text/javascript>// Created by: Ivan Iraola :: http://www.cybexmag.comfunction 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");  }}</script><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


HTML
<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><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->