Introduction

After taking a look at
SearchLite , the Javascript program I wrote to search
multiple search-engines at once, a friend complained about all the
new windows that opened for each site. He wished he could get all the
results from multiple sites on a single page. We got thinking and I
implemented this solution using IFRAME .

The wonderful thing about IFRAME is that its supported both by IE and
Netscape 6. It is good for developers that finally both IE and Netscape are
complying with W3C standards.

Although Netscape introduced several pioneering browser features, in recent
times, it has not been able to catch up with IE and it has long been
the
butt of jokes. Netscape 6, based on Gecko, is a
major upgrade over version 4 and sports a
new look now. Gecko is the rendering engine
of the Mozilla
open source project. Gecko is embeddable, free,
and open source. Bugzilla
is the bug-tracking system used by the Mozilla project.

IFRAME

The IFRAME element allows HTML content from one
document to be loaded within the body of another document.

The following are some of the properties common to Netscape 6 and
IE -

ID - Retrieves the string identifying the object.

FRAMEBORDER - Sets or retrieves whether to display a border for the frame.
Possible Values are 1/yes/0/no.

SCROLLING - Sets or retrieves whether the frame can be scrolled. Possible
Values are yes/no.

SRC - Sets or retrieves a URL to be loaded within the inline frame

WIDTH,HEIGHT - Sets or retrieves the width and height.

The LAYER tag is no longer supported in Netscape 6. More
exhaustive information about IFRAME can be
found here

The Source

For understandability and just in case you haven't taken a
peek at SearchLite,
let me just re-hash the way the script works. Information can be posted using a HTML Form through the
GET or POST method. If a site uses the
GET method, the values that are submitted by the user
are visible in the URL.

Taking advantage of this particular QueryString feature we
can dynamically build a URL based on the Site and the Keyword specified.
For instance by placing a keyword at the end of this URL
http://www.google.com/search?hl=en&btnG=Google+Search&q=
, I can search on Google without having to actually visit their
homepage. HTML cannot handle certain special characters and so care
must be taken to escape them so that the URL is a valid
one and the parameters are properly received.

Javascript has a function called escape() which does the job. The escape function encodes special characters in
the specified string and returns the new string. It encodes spaces,
punctuation, and any other character that is not an ASCII alphanumeric character,
with the exception of these characters: * @ - _ + . /

By noticing the URL of other Search engines this script can be customized to handle
any other sites which use the GET method to accept search keywords. SearchLite v2 uses IFRAMEs to show results
of multiple sites on a single page. Initially all the IFRAME
elements are hidden using CSS (the good news is Netscape 6 fully supports the
CSS1 standard) in the BODY onLoad event.

Depending on how many checkboxes corresponding to the sites to be
searched are clicked, an equivalent number of IFRAME
elements are made visible. Only as many IFRAME elements as
needed are shown. The URL that is dynamically created based on the keyword
specified is set to the SRC property of IFRAME
.The function below is activated on-clicking the FIND button

After you unzip the source file, run it in IE or Netscape 6....and do let me
know what you felt about it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

Share

About the Author

'Anil' Radhakrishna is a seasoned developer who enjoys working with Microsoft tools & technologies. He blogs quite regularly about his little discoveries and technical experiments on his blog called Tech Tips, Tricks & Trivia. You can find some of his unusual code samples & snippets at his Code Gallery. He loves building mash-ups using public Web APIs.

Comments and Discussions

One problem I spotted is that if you reset a search, and check different engines, it doesn't take away the old searches (i.e. if I search with 3 sites checked, then search again with just 1, it still displays the last 2 results from the original search)