Connecting Tech Pros Worldwide Forums | Help | Site Map

Re: To add search in my page

Betikci Boris
Guest
 
Posts: n/a
#1: Sep 4 '08
On Sep 4, 11:01*pm, Betikci Boris <pard...@gmail.comwrote:
Quote:
On Sep 4, 3:21*pm, lak <lakindi...@gmail.comwrote:
>
Quote:
I want to search within my page. How can I do that. When I searched in
the net, it tells to use the google search. But I want to do for my
web page. I am using intra-net system.
>
If i unterstood correctly, you do not have too much content right.
ex. if *you do not have much than 1500 - 2000 pages, you can simple
use javascript for search.
>
use arrays to store your data, which will be used, available for
search process;
>
Ex. var data = new Array();
>
data[content] = new Array();
>
data[content][0] = ["x.html","keyword","keyword1","keyword2" ...
"keywordn"];
__________________________________________________ ______________________________
<script language="javascript">
// Author: Barış ÇUHADAR, Licence: GPL..
var c = new String(window.location); //http://foo.com/x.php?q=keyword
var s = c.split("="); // gets the keyword after "="
var flag = 0;
>
if(s[1])
{
* * s[1]=decodeURI(s[1]);
>
* * for(var i = 0; i < 3; i++)
* * {
* * * * for(var j = 0; j < site_data["content"][i]["keywords"].length;
j++)
* * * * * * if(site_data["content"][i]["keywords"][j].match(s[1]))
* * * * * * {
* * * * * * * * document.write("<a href="+site_data["content"][i][0]
[0]+">"+site_data["content"][i][0][1]+"</a>");
* * * * * * * * document.write("<br>");
* * * * * * * * document.write(site_data["content"][i][0][2]);
* * * * * * * * document.write("<br>");
* * * * * * * * document.write("<br>");
* * * * * * * * flag = 1;
* * * * * * }
* * * * * * else if(flag !=1) { flag = 2;}
* * }
* * if(flag == 2)
* * {
* * * * document.write("nothing found");
* * }}
>
else if(flag == 0) { document.write("enter something to search");}
>
</script>
__________________________________________________ _____________________
>
when you search within keywords by a loop, you can simply built a
simple js search engine skeleton.
I use this approach in Interactive-CD's + SQLite3 + PHP

Closed Thread