473,395 Members | 1,647 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Local jawascript search to search pages from only my website

HI
I want a jawascript that will search pages from only my subdomain
website eg. abc.efg.com
can anyone help me
please give the exact jawascript as I am not an expert programmer
please if possible email it to in***************@gmail.com
awaiting
Manish wagh
Nov 8 '08 #1
5 2414
rf

"manish" <in***************@gmail.comwrote in message
news:23**********************************@r37g2000 prr.googlegroups.com...
HI
I want a jawascript that will search pages from only my subdomain
website eg. abc.efg.com
can anyone help me
please give the exact jawascript as I am not an expert programmer
How is that going to help? Your Javascript lives on one single page. All the
other pages that need to be searched live on your host. Whatever you do you
will need a server side solution.
please if possible email it to in***************@gmail.com
Nope.
Nov 8 '08 #2
manish wrote:
I want a jawascript that will search pages from only my subdomain
website eg. abc.efg.com
----------------------------------------------------------------
START CODE
----------------------------------------------------------------

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
<title>Search</title>
<script type="text/javascript">
var xhr;
var pages = ['1.htm', '2.htm', '3.htm', '4.htm', '5.htm'];

function do_srch(q) {
document.getElementById('results').innerHTML = '';
document.getElementById('restitle').innerHTML =
'<h3>Search results for \'<i>' + q + '<\/i>\'<\/h3>\n';
for (var i=0; i<pages.length; i++) fetch(pages[i], q);
if (document.getElementById('results').innerHTML == '') {
document.getElementById('results').innerHTML = 'No results';
}
}

function fetch(page, q) {
xhr = null;
if (window.XMLHttpRequest) {
xhr = new XMLHttpRequest();
}
else if (window.ActiveXObject) {
xhr = new ActiveXObject('Microsoft.XMLHTTP');
}
if (xhr != null) {
xhr.open('GET', page +'?' + (new Date()).getTime(), false);
xhr.send(null);
if (xhr.readyState == 4) {
if (xhr.status == 200) {
q = q.replace(
/(\\|\^|\$|\*|\+|\?|\.|\{|\}|\(|\)|\:|\=|\!|\||\,|\[|\])/g,
'\\$1');
if ((new RegExp(q)).test(xhr.responseText))
document.getElementById('results').innerHTML +=
'<a target="_blank" href="'+page+'">'+page+'<\/a><br>
\n';
}
}
}
}
</script>
</head>
<body>
<form action="#"
onSubmit="do_srch(document.forms[0].q.value); return false;">
<input size="40" type="text" name="q" value="apple">
<input type="submit" value="Search">
</form>
<div id="restitle"></div>
<div id="results"></div>
</body>
</html>

----------------------------------------------------------------
END CODE
----------------------------------------------------------------

And the following pages to search:
1.htm: <html><body>2 apples and 1 pear</body></html>
2.htm: <html><body>3 oranges and 1 kiwi *</body></html>
3.htm: <html><body>4 pears and 1 app
le</body></html>
4.htm: <html><body>Apples are great! \</body></html>
5.htm: <html><body>two apples</body></html>

See the direct demo at:
http://www.dotinternet.be/temp/xhr_src/xhr_src.htm

All files need to be placed on your same subdomain 'abc.efg.com'.
Wildcards are not allowed in the search queries. The search is case-
sensitive.

This demo works with defined files that are to be searched (see the
'pages'-variable). If you want XMLHttpRequest to search all files in a
directory, then you could do something like
http://groups.google.com/group/comp....f704292a72a661

Hope this helps,

--
Bart
Nov 8 '08 #3
Bart Van der Donck <ba**@nijlen.comwrote in news:567bf9f1-aa40-44ff-8781-
2e**********@e38g2000prn.googlegroups.com:
....
xhr = new ActiveXObject('Microsoft.XMLHTTP');
....
http://groups.google.com/group/comp....f704292a72a661
Will these methods work with non-MS browsers?
Nov 8 '08 #4
Mike Duffy meinte:
Bart Van der Donck <ba**@nijlen.comwrote in news:567bf9f1-aa40-44ff-8781-
2e**********@e38g2000prn.googlegroups.com:
>....
xhr = new ActiveXObject('Microsoft.XMLHTTP');
>....
http://groups.google.com/group/comp....f704292a72a661

Will these methods work with non-MS browsers?

If properly coded - yes.

Gregor
Nov 8 '08 #5
Mike Duffy wrote:
Bart Van der Donck <b...@nijlen.comwrote in news:567bf9f1-aa40-44ff-
8781-2ef8d8fa9...@e38g2000prn.googlegroups.com:
>....
* *xhr = new ActiveXObject('Microsoft.XMLHTTP');
....
Will these methods work with non-MS browsers?
Non-Microsoft browsers should support window.XMLHttpRequest. The
ActiveXObject call is for backwards compatibility with MSIE <7.

http://en.wikipedia.org/wiki/XMLHttp...ry_and_support

"The XMLHttpRequest concept was originally developed by
Microsoft [...] It has been available since the introduction
of Internet Explorer 5.0* [...] Internet Explorer versions prior
to 7.0 require XMLHTTP to be invoked as an ActiveXObject [...]
The Mozilla project incorporated the first compatible native
implementation of XMLHttpRequest in Mozilla 1.0 in 2002. This
implementation was later followed by Apple since Safari 1.2,
Konqueror, Opera Software since Opera 8.0, iCab since 3.0b352,
and Microsoft since Internet Explorer 7.0."

* = March 1999
see http://en.wikipedia.org/wiki/Internet_Explorer_5

--
Bart
Nov 8 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: bissatch | last post by:
Hi, I am about to build a web site that contains a news section. Basically, the site owner will login to an admin section and from there, be able to add news. What I would like to know is how...
0
by: R. Rajesh Jeba Anbiah | last post by:
Q: Is PHP search engine friendly? Q: Will search engine spiders crawl my PHP pages? A: Spiders should crawl anything provided they're accessible. Since, nowadays most of the websites are been...
67
by: Sandy.Pittendrigh | last post by:
Here's a question I don't know the answer to: I have a friend who makes very expensive, hand-made bamboo flyrods. He's widely recognized (in the fishing industry) as one of the 3-5 'best' rod...
4
by: Ove | last post by:
I have one Access 2000 DB on my website. I want to access these tables from my local database so i do not need to down-/upload the database each time i want to make changes. Meanwhile i want a...
11
by: emailus | last post by:
I am webmaster for the domain <www.alpha1.org.au>. Not being an expert in html, I take advantage of my domain Registrant's web building tool, 'Instant Website'. This tool is provided as part of...
8
by: Roman | last post by:
I received a marketing call from a guy first showing me my website and then some other website and ranking of that other website. My questions is it worth paying to SEO corporation a $1200 -...
6
by: =?Utf-8?B?cm9kY2hhcg==?= | last post by:
hey all, what determines how high a website's ranking will appear after being searched? what can i do to my website to give it a good chance of being ranked pretty high? thanks, rodchar
7
nukefusion
by: nukefusion | last post by:
Hi all, I'm trying to think of the best way to achieve a certain goal and thought I would draw on the experience here. What I am currently doing is compiling a set of HTML files that form the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.