Snap Builder Public Codes Library
Snap | Generators | Login | Browse | Search | Enter Code | Export Snap Builder Public Codes Library


Category: Javascript Codes Library >> Miscellaneous Snippets >> Web Page Search

Code Snippet </> Info

Snippet Name: Web Page Search

Description: Put a web page search form box on your web page. Ideal for long pages with lots of content.

Compatible Browsers:
Internet Explorer Browser

Note: Place any where on your web page.

Author: SnapBuilder <>

Last Modified: 2019-12-09 21:57:24

Language: javascript

Highlight Mode: javascript

Copy Codes: Use Free Notepad ++
Bookmark and Share

Snap HTML Code Editor:
Paste the source code, make changes and instantly see it in live preview.
Snap HTML Code Editor

  About Copying
Copied To Clipboard!

<html> <head> <title>Page Search Engine</title> </head> <body> <script> <!-- Begin Search Page Script from --> var NS4 = (document.layers); var IE4 = (document.all); var win = window; var n = 0; function findInPage(str) { var txt, i, found; if (str == "") return false; if (NS4) { if (!win.find(str)) while(win.find(str, false, true)) n++; else n++; if (n == 0) alert("No Match Found!"); } if (IE4) { txt = win.document.body.createTextRange(); for (i = 0; i <= n && (found = txt.findText(str)) != false; i++) { txt.moveStart("character", 1); txt.moveEnd("textedit"); } if (found) { txt.moveStart("character", -1); txt.findText(str);; txt.scrollIntoView(); n++; } else { if (n > 0) { n = 0; findInPage(str); } else alert("Sorry, we could not find any match. Please try another search phrase."); } } return false; } </script> <form name="search" onsubmit="return findInPage(this.string.value);"> <p align="center"><font size="3"> <input style="border-right:#dddddd 1px solid; border-top:#dddddd 1px solid; font-size:12px; boder-left:#dddddd 1px solid; border-bottom:#dddddd 1px solid" onchange="n = 0;" size="16" name="string"></font><br /><input style="border-right:#ffffff 1px solid; border-top:#ffffff 1px solid; font-size:12px; border-left:#ffffff 1px solid; border-bottom:#ffffff 1px solid; font-family:Arial; background-color:#eeeeee" type="submit" value="Search"> </p></form></div> <!-- /Search--> [ Your Content Goes Here ] </body> </html>

[ Snippet Options ]


© 2002 -  Snap Builder Public Codes Library