Chapter 4. The Multiple Search Engine Interface

Application FeaturesJavaScript Techniques
• Frames-Based Multiple Search Engine• Reusing Your Code
• Single-Click Searching• Foregoing OO
• Simple Search Engine Management• Math Versus Memory
 • Using escape()

Multiple search engine apps written in JavaScript abound on the Net. This kind of application is one of the coolest and potentially easiest things to develop in JavaScript. And why not? You can capitalize on OPD (other people’s data) to make your web site a portal to the network universe. This is my version. There are certainly more robust applications out there, but this one gives you significant advantages fairly easily. Figure 4.1 shows the first look as you open ch04/index.htmlin your browser.

Using this application isn’t complicated. The user enters query text in the bottom left corner, then uses the arrows to advance through a layer-based menu of available search engines. All the user needs to do is click on the button of the search engine he or she wants to send the query text to, and the results show up in the center frame. I searched the Image Surfer database for the term “andromeda” and received the results shown in Figure 4.2.

The multiple search engine interface

Figure 4-1. The multiple search engine interface

Image Surfer returns pictures in its database associated with the term “andromeda”

Figure 4-2. Image Surfer returns pictures in its database associated with the term “andromeda”

That’s really all there is to it. Notice the search results frame is surrounded by a black border. That’s my award-winning attempt at web page design. It’s a personal preference and easy to change to a more basic two-frame (top and bottom) layout.

By the way, if you’ve been following the chapters in order, you’ll soon notice that this one is different in that it doesn’t present entirely new code. Actually, I’ll show you how to get extra mileage out of the code we covered in Chapter 3. This will be a great way to see how you can reapply code that you already have to save time.

Execution Requirements

This application uses DHTML, so you’ll need NN or MSIE 4.x to use it. I included 20 search engines. The number of search engines you use can easily reach the hundreds. But that’s probably more than the average user will ever need. Keep in mind, too, that this application might run really well on your local machine, but, as with the slideshow, lots of graphics will increase the load time for Internet users.

Get JavaScript Application Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.