Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-28-2010, 01:15 AM   PM User | #1
fleewood
New Coder

 
Join Date: Jun 2010
Posts: 42
Thanks: 2
Thanked 0 Times in 0 Posts
fleewood is an unknown quantity at this point
Simple Javascript Search Engine

Can anyone get me a simple script for a search engine for my website? i cant find a decent 1 anywhere. thanks
fleewood is offline   Reply With Quote
Old 07-28-2010, 01:22 AM   PM User | #2
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,210
Thanks: 59
Thanked 3,996 Times in 3,965 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
You can't write a search engine in JavaScript.

Which is probably why you can't find a decent one.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Old 07-28-2010, 04:38 PM   PM User | #3
fleewood
New Coder

 
Join Date: Jun 2010
Posts: 42
Thanks: 2
Thanked 0 Times in 0 Posts
fleewood is an unknown quantity at this point
whats the easiest way to get a search engine on my website then?
fleewood is offline   Reply With Quote
Old 07-28-2010, 05:26 PM   PM User | #4
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,037
Thanks: 197
Thanked 2,411 Times in 2,389 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
Use Google.


Code:
<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>

Last edited by Philip M; 07-28-2010 at 05:30 PM..
Philip M is offline   Reply With Quote
Old 07-28-2010, 06:35 PM   PM User | #5
fleewood
New Coder

 
Join Date: Jun 2010
Posts: 42
Thanks: 2
Thanked 0 Times in 0 Posts
fleewood is an unknown quantity at this point
not what i meant. I need a search engine to search what is on my website...
fleewood is offline   Reply With Quote
Old 07-28-2010, 06:57 PM   PM User | #6
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,037
Thanks: 197
Thanked 2,411 Times in 2,389 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
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.

Last edited by Philip M; 07-28-2010 at 07:02 PM..
Philip M is offline   Reply With Quote
Old 07-28-2010, 08:12 PM   PM User | #7
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,210
Thanks: 59
Thanked 3,996 Times in 3,965 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
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:
Code:
var googleSearch = 
    "http://www.google.com/search?hl=en&source=hp&as_sitesearch=www.yourdomainname.com&q=" + input;
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:40 AM.


Advertisement
Log in to turn off these ads.