...

View Full Version : Simple Javascript Search Engine



fleewood
07-28-2010, 02:15 AM
Can anyone get me a simple script for a search engine for my website? i cant find a decent 1 anywhere. thanks

Old Pedant
07-28-2010, 02:22 AM
You can't write a search engine in JavaScript.

Which is probably why you can't find a decent one.

fleewood
07-28-2010, 05:38 PM
whats the easiest way to get a search engine on my website then?

Philip M
07-28-2010, 06:26 PM
Use Google.



<input type = "text" size = "40" style=" border-color:#000000;border-width:1px;"; id = "searchTerm">
<br><br>
<input type="button" value="Google Search" style="background-color:gold; font-weight:bold; width:180;height:30"; onclick="google()">
<br><br>

<script type = "text/javascript">
function google() {
var input = document.getElementById("searchTerm").value;
if (input.length > 2) {
var googleSearch = "http://www.google.ca/search?hl=en&source=hp&q=" + input;
document.location.href = googleSearch;
}
}
</script>

fleewood
07-28-2010, 07:35 PM
not what i meant. I need a search engine to search what is on my website...

Philip M
07-28-2010, 07:57 PM
You might consider http://www.tesol.net/scripts/SillySearch/
It is a Perl/cgi script which I have found very useful with a little tweaking.
Naturally you must be able to execute cgi programs on your web server.

Old Pedant
07-28-2010, 09:12 PM
You can use google, but it only works if google has fully indexed your site.

You simply specify your site's domain name as part of the search criteria.

Use Philip's code from post #4 but just add as_sitesearch to the list of querystring arguments:


var googleSearch =
"http://www.google.com/search?hl=en&source=hp&as_sitesearch=www.yourdomainname.com&q=" + input;



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum