Web Images Videos Maps News Shopping Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Group info
Members: 21
Language: English
Group categories:
Computers > Databases
Computers > Programming
Computers
More group info »
Recent pages and files
search-your-site-with-javascript-xml-and-css-part-one    

Any site that is popular with users of the 'net, while unique andindividual in certain aspects, will share particular attributes withother popular sites; aside from interesting or useful content, they'relikely to feature things such as an easy to use navigation model, asensibly laid out sitemap, and the ability to search for specificinformation or content (there are other things as well, this isn?teverything you need to cover!).? The ability to perform searches forspecific information is especially important for larger sites anddynamic sites, which often implement the search via server-sidetechnology.?Having a decent and dependable search engine on smaller sites neednot be a pipedream either however so don't think that for smaller sitesit isn't necessary to include a search facility.? Making things easierfor visitors should be right at the top of any web designer's list ofpriorities because if no concern is given in this area, there won't beany visitors!? If you don?t have access to server-side technology suchas PHP or ASP.NET you needn't worry as during the course of thisarticle I'm going to show you how easy it is to create a purelyclient-side search engine that will happily search any number of pagesfor words entered into a simple text box.


We will be using a variety of techniques to accomplish this; initiallywe're going to need an html page to hold the search box the visitorenters their search strings into, and also to display the results ofthe search on.? My last two-part article looked at storing data in anXML file and extracting it to work with and in this article we are alsogoing to make use of this technique.? JavaScript has no access to theweb-server file system, so we cannot use it to scan the root directoryof your site for HTML files.? We need a way to tell the search enginewhich pages to look at when performing a search.? As before, we willuse an XML file to hold the URLs of all of the pages the search enginescript is to look at.? There are many benefits in having a centralisedstore of data to use in scripts such as this and makes maintaining thesearch engine very easy because if you add a new page to your site thatyou want to include in searches, all you need to do is add the URL ofthe page to the XML file.? Finally, we can use CSS to control theappearance of both the search box and the results.? As always, we willalso be taking standards compliance and accessibility intoconsideration in all of the documents we create.

For the purpose of this tutorial, the search box and results will becontained on a page by themselves with no other code or page elementsto get in the way or confuse things, although there is no reason whythe search box can?t be placed, say, at the bottom of a verticalnavigation menu, or in the page header for example.? To run the codelocally, you should create a new directory somewhere that you can placethe associated files into.? You'll also need a couple of HTML pageswith some dummy content in that you can do test searches on.? These canbe of the very bare minimum standard required and are just required tofollow the article.? They won?t be used in a production environment sothey don?t need to be valid documents, just something with some contentin them.


Read more

Version: 
Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google