By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,712 Members | 2,063 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,712 IT Pros & Developers. It's quick & easy.

To add search in my page

P: n/a
lak
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.
Sep 4 '08 #1
Share this Question
Share on Google+
12 Replies


P: n/a
lak 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.
You'll need to build a search engine which examines the generated html
for every page, parses it into the appropriate words, catalogs those
words in a database, then matches the search arguments to each word.

Unless, of course, you want to search every page on every search, in
which case you don't need to store the words in a database. But such a
search, unless you have a very few number of pages, will take much longer.

Such a search function is not easy to implement. But if you need it,
probably the best way is to set your site up with one of the CMS's which
has it already built in.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Sep 4 '08 #2

P: n/a
On Sep 4, 3:21*pm, lak <lakindi...@gmail.comwrote:
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.
Sep 4 '08 #3

P: n/a
Betikci Boris wrote:
On Sep 4, 3:21 pm, lak <lakindi...@gmail.comwrote:
>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.
Such an important site feature shouldn't rely upon JavaScript, which
can be disabled or unavailable. Also, when serving content as
application/xhtml+xml, document.write() is not an option, you need to
use DOM manipulation.

--
Curtis
Sep 5 '08 #4

P: n/a
AqD
On Sep 4, 8:21*pm, lak <lakindi...@gmail.comwrote:
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 you want only page-based search, there are free search engines for
whole websites (like another google for your site).

Or you can use Zend search engine, part of the Zend framework. It's a
port of java Lucene and can be customized to search in common objects
(= everything you can get); It also supports custom weighting,
keywords, language, etc. But it would require some coding by yourself
and I'm not sure how many people actually use it for real-world
projects (java's Lucene itself is popular and widely-used though)
Sep 5 '08 #5

P: n/a
lak 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.

Zend has a port of Java Lucene that works very well.
Creating the index can be slow, especially if you are--for
instance--indexing thousands of pages in a forum. So slow it
will time out on a shared-host.

You can write a small utility in java, which runs as an
application on the shared host. You will need to upload
the latest lucene.jar. Zend's php Lucene doesn't know
the index was made with java, and the queries work just fine.

Or you can download the search-source to a desktop box,
bump max execution time on your local php.ini and then
make the index with php locally....and then ftp it up
to the shared host.

If you have your own server, none of the above is your
problem. The searches are plenty fast enough and they give
very good results. You'll have to read the tutorials and
roll your own results display. But that isn't hard.

--
cut the board three times and it's still too short
Sep 5 '08 #6

P: n/a
>Such an important site feature shouldn't rely upon JavaScript, which
>can be disabled or unavailable. Also, when serving content as
application/xhtml+xml, document.write() is not an option, you need to
use DOM manipulation.
Yes possible. However my approach can be used with PHP regarding the
case of site security and maintenance.

I love JavaScript and using it ;)
Sep 5 '08 #7

P: n/a
Betikci Boris wrote:
>Such an important site feature shouldn't rely upon JavaScript, which
can be disabled or unavailable. Also, when serving content as
application/xhtml+xml, document.write() is not an option, you need to
use DOM manipulation.

Yes possible. However my approach can be used with PHP regarding the
case of site security and maintenance.

I love JavaScript and using it ;)
And it fails on 100% of the clients which have javascript disabled.

I use javascript to enhance the visiting experience. But I don't rely
on it.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Sep 5 '08 #8

P: n/a
AqD
On Sep 6, 2:57*am, Jerry Stuckle <jstuck...@attglobal.netwrote:
Betikci Boris wrote:
Such an important site feature shouldn't rely upon JavaScript, which
can be disabled or unavailable. Also, when serving content as
application/xhtml+xml, document.write() is not an option, you need to
use DOM manipulation.
Yes possible. However my approach can be used with PHP regarding the
case of site security and maintenance.
I love JavaScript and using it ;)

And it fails on 100% of the clients which have javascript disabled.
If the clients do disable javascript, they would have much more to
worry than than your websites ;)
>
I use javascript to enhance the visiting experience. *But I don't rely
on it.
Things get nasty when you have to use ajax like in gmail. Depending on
the target customers, usually I try to keep javascript code compatible
with all major browsers, but if somebody doesn't like javascript (like
myself when i use IE), well he would just have to turn it on or go
away.
Sep 8 '08 #9

P: n/a
AqD wrote:
On Sep 6, 2:57 am, Jerry Stuckle <jstuck...@attglobal.netwrote:
>Betikci Boris wrote:
>>>Such an important site feature shouldn't rely upon JavaScript, which
can be disabled or unavailable. Also, when serving content as
application/xhtml+xml, document.write() is not an option, you need to
use DOM manipulation.
Yes possible. However my approach can be used with PHP regarding the
case of site security and maintenance.
I love JavaScript and using it ;)
And it fails on 100% of the clients which have javascript disabled.

If the clients do disable javascript, they would have much more to
worry than than your websites ;)
Yet about 10% of users do disable javascript, for one reason or another.
>I use javascript to enhance the visiting experience. But I don't rely
on it.

Things get nasty when you have to use ajax like in gmail. Depending on
the target customers, usually I try to keep javascript code compatible
with all major browsers, but if somebody doesn't like javascript (like
myself when i use IE), well he would just have to turn it on or go
away.
And they will go away, which means lost potential sales. Do you tell
10% of your potential customers without even knowing what they want?
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Sep 8 '08 #10

P: n/a
AqD
On Sep 8, 10:19*am, Jerry Stuckle <jstuck...@attglobal.netwrote:
AqD wrote:
On Sep 6, 2:57 am, Jerry Stuckle <jstuck...@attglobal.netwrote:
Betikci Boris wrote:
Such an important site feature shouldn't rely upon JavaScript, which
can be disabled or unavailable. Also, when serving content as
application/xhtml+xml, document.write() is not an option, you need to
use DOM manipulation.
Yes possible. However my approach can be used with PHP regarding the
case of site security and maintenance.
I love JavaScript and using it ;)
And it fails on 100% of the clients which have javascript disabled.
If the clients do disable javascript, they would have much more to
worry than than your websites ;)

Yet about 10% of users do disable javascript, for one reason or another.
I use javascript to enhance the visiting experience. *But I don't rely
on it.
Things get nasty when you have to use ajax like in gmail. Depending on
the target customers, usually I try to keep javascript code compatible
with all major browsers, but if somebody doesn't like javascript (like
myself when i use IE), well he would just have to turn it on or go
away.

And they will go away, which means lost potential sales. *Do you tell
10% of your potential customers without even knowing what they want?
It's not 10% here (.tw), more like 1% or 0.01%. A lot of websites here
require javascript and even vbscript and ActiveX (non-certificated!).
And you could find many "tutorials" that tell people to set low
security level in IE...

I don't know about people of other countries. But I think most people
wouldn't bother to turn on/off javascript or anything.
Sep 8 '08 #11

P: n/a
AqD wrote:
On Sep 8, 10:19 am, Jerry Stuckle <jstuck...@attglobal.netwrote:
>AqD wrote:
>>On Sep 6, 2:57 am, Jerry Stuckle <jstuck...@attglobal.netwrote:
Betikci Boris wrote:
>Such an important site feature shouldn't rely upon JavaScript, which
>can be disabled or unavailable. Also, when serving content as
>application/xhtml+xml, document.write() is not an option, you need to
>use DOM manipulation.
Yes possible. However my approach can be used with PHP regarding the
case of site security and maintenance.
I love JavaScript and using it ;)
And it fails on 100% of the clients which have javascript disabled.
If the clients do disable javascript, they would have much more to
worry than than your websites ;)
Yet about 10% of users do disable javascript, for one reason or another.
>>>I use javascript to enhance the visiting experience. But I don't rely
on it.
Things get nasty when you have to use ajax like in gmail. Depending on
the target customers, usually I try to keep javascript code compatible
with all major browsers, but if somebody doesn't like javascript (like
myself when i use IE), well he would just have to turn it on or go
away.
And they will go away, which means lost potential sales. Do you tell
10% of your potential customers without even knowing what they want?

It's not 10% here (.tw), more like 1% or 0.01%. A lot of websites here
require javascript and even vbscript and ActiveX (non-certificated!).
And you could find many "tutorials" that tell people to set low
security level in IE...

I don't know about people of other countries. But I think most people
wouldn't bother to turn on/off javascript or anything.
You might underestimate the impact of those who use text-based
browsers like lynx, in addition to the security conscious. Then
there's still those with outdated browsers, which may not implement a
recent enough JS engine.

Since Firefox is so popular (and many of its add-ons), it's quite
possible to restrict JS execution based on a white list access
security policy (NoScript). I use it, for one, and so do many others.

There's simply no reason to require JS for fundamental site features
like navigation or searching.

Requiring ActiveX is just ridiculous, I would never adhere to any
site's requirement of that type, other than Microsoft's.

--
Curtis
Sep 8 '08 #12

P: n/a
AqD wrote:
On Sep 8, 10:19 am, Jerry Stuckle <jstuck...@attglobal.netwrote:
>AqD wrote:
>>On Sep 6, 2:57 am, Jerry Stuckle <jstuck...@attglobal.netwrote:
Betikci Boris wrote:
>Such an important site feature shouldn't rely upon JavaScript, which
>can be disabled or unavailable. Also, when serving content as
>application/xhtml+xml, document.write() is not an option, you need to
>use DOM manipulation.
Yes possible. However my approach can be used with PHP regarding the
case of site security and maintenance.
I love JavaScript and using it ;)
And it fails on 100% of the clients which have javascript disabled.
If the clients do disable javascript, they would have much more to
worry than than your websites ;)
Yet about 10% of users do disable javascript, for one reason or another.
>>>I use javascript to enhance the visiting experience. But I don't rely
on it.
Things get nasty when you have to use ajax like in gmail. Depending on
the target customers, usually I try to keep javascript code compatible
with all major browsers, but if somebody doesn't like javascript (like
myself when i use IE), well he would just have to turn it on or go
away.
And they will go away, which means lost potential sales. Do you tell
10% of your potential customers without even knowing what they want?

It's not 10% here (.tw), more like 1% or 0.01%. A lot of websites here
require javascript and even vbscript and ActiveX (non-certificated!).
And you could find many "tutorials" that tell people to set low
security level in IE...

I don't know about people of other countries. But I think most people
wouldn't bother to turn on/off javascript or anything.
So what? You are not the world. And if you want to drive people way
from your sites, that's your choice.

And what you THINK is completely irrelevant. I'm going by statistics
seen in the logs of multiple sites. They vary, depending on the target
audience of the site. But the lowest is about 5%.

Maybe you only see 0.1% because those who don't have it enabled don't
come back.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Sep 8 '08 #13

This discussion thread is closed

Replies have been disabled for this discussion.