Click to See Complete Forum and Search --> : search site images


marika
10-06-2003, 07:24 AM
I know little javascript and I need to implement a simple search engine for a small website. Basically just a search box and a search button, to search only the specific website. Like search for "demo tape".
However the search is only to search for photographs on the site, and not for text.
Can anyone tell me how I would go about this? Can the search be based on the alt of the images? Or I could list keywords for the photographs on each page, so the search would only come up with pages containing the keywords, that is the images?
Can anyone help? Also can anyone point me in a direction for a javascript tutorial or explanation as to how to create a simple search engine and the different possibilities?
Thank you, Marika Ludmann

Khalid Ali
10-06-2003, 09:39 AM
yes you can do a search on alt of an image tag.

get all images in the document

var imagesList = document.getElementsByTagName("img");

Now you can loop through the imagesList(just ike an array)
and get each image objects alt property and compare it with search string