Re: To add search in my page



On Sep 4, 3:21 pm, lak <lakindi...@xxxxxxxxx> wrote:
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.
.



Relevant Pages

  • Re: To add search in my page
    ... I am using intra-net system. ... var data = new Array; ... Such an important site feature shouldn't rely upon JavaScript, which can be disabled or unavailable. ...
    (comp.lang.php)
  • Re: To add search in my page
    ... it tells to use the google search. ... I am using intra-net system. ... var data = new Array; ...
    (comp.lang.php)