Forum Moderators: open

Message Too Old, No Replies

Making a Search Box

         

Woz

9:59 am on Mar 1, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have been thinking about the "search box vs link to a search page" [webmasterworld.com] discussion a little and I guess it depends on the site to a large extent. For a Search Engine or Directory of course the search box is somewhat mandatory, but for a site where you want more leeway inleading your visitor then it could distract them from your preferred navigation pathway.

However, I don't like having to load a new page just to do a simple search; an advanced search? yes, but simple search? no.

I am thinking that a good compromise, and one I would like to test, might be to have a clickable link that brings up a dialog box which then sends the entered search term/s to the search page as a querystring. Similar to the Google Search link you can load on the IE Links bar.

As I am not a Javascript person, could somebody suggest how that could be done?

Onya
Woz

joshie76

10:10 am on Mar 1, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Something like this what you're after?

<script>
function showSearch()
{
document.getElementById('search').style.visibility = 'visible';
document.getElementById('search').style.top = event.clientY;
document.getElementById('search').style.left = event.clientX;
}
</script>

<body>
<a href="javascript:;" onclick="javascript:showSearch()">search</a>
<div id="search" style="position:absolute;visibility:hidden;background-color:ivory;border:#cc6600 1px solid;padding:10px"><input type="text" name="search"> <input type="submit" value="go!"></div>
</body>

It wouldn't work in NN4 though I'm sure one of our cross-browser peeps could sort that.

tedster

11:03 am on Mar 1, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Here's a little aside about the pitfalls of coding a search function. If you go to Overture right now with Opera, identified as Opera, the search box does NOT show on the first page!

I like the idea of making a search box invisible until a link is clicked, rather than making it load an entirely new page. Although we do not explicitly support NN4 on the site in question (layouts may be off, etc,) we wouldn't want the poor browser to be completely dysfunctional on every page.

Another thought that occurs to me here, thanks to the comments on this thread, is that serving the regular user on this site has different requirements than serving the first time visitor. The site will have two levels of registered access, and those who are signed up deserve easy access to the search function.

The new visitor is a different critter, one who we want to entice into sticking around and coming back and registering. The site search engine will be relatively limited in what it can return to a guest user in any case.