Industry guru Dave Taylor offers free tech support on a wide variety of technical and business topics, including HTML, Apple iPhone, online advertising, Cascading Style Sheets, Web design, management, Unix, Linux, search engine optimization, online dating, Mac OS X, shell script programming and Microsoft Windows.

How do I add an Ask.Com seach box to my Web site?

What is the HTML needed to add an ASK.COM search box or search form to my web page? Thanks.


Dave's Answer:

Apparently one great benefit of learning the arcane hypertext markup language (HTML) is that I can crack open Web pages, figure out how the scripts on those pages work and rewrite them to appear on other Web pages or web sites. It's actually kind of a fun little puzzle, but I wouldn't admit that in public lest it make me sound like a bit of a geek. :-)

Anyway, the first step is to bring up a page with the search box you want. In the case of Ask.com I suggest that you start with the search box at the top of a search results page, since it's simpler code than their fancy home page.

When I searched for actor Johnny Depp, it looks like this:

ask johnny depp results

The source code is accessible by choosing View --> Page Source in Firefox or similar in whatever browser you use.

The source is a jumble of complex codes and scripts, as is common on modern sites, but underneath all of that is the core functionality of the search box. When you dig through it, however, you find that the way that they've implemented the search suggestions script means that you can't just extract the form HTML elements and have a functional script. Too bad.

Instead, we'll have to reverse engineer the URL that's produced on a search.

The page that I show above, for example, has the complicated URL:

http://www.ask.com/web?q=johnny+depp&search=search&qsrc=0&o=0&l=dir

Unwrapped this means that we have a bunch of variable=value pairs:

  • q=johnny+depp
  • search=search
  • qsrc=0
  • o=0
  • l=dir
Usually in my experience, almost all of these variables are unnecessary, which can be easily tested by stripping out the search to its most fundamental element: the search pattern.

This gives us the following URL: http://www.ask.com/web?q=johnny+depp.

Click on it and see what happens.

It works!

Nice. This means that the Ask.com search box is incredibly simple:

<form method="get" action="http://www.ask.com/web" />
  <input type="text" name="q" />
  <input type="submit" value="search ask.com" />
</form>

Easy enough!

Now that you have the most basic search box you can jazz it up with some Cascading Style Sheet (CSS) code if you'd like, to make it a bit more fun:

<form method="get" action="http://www.ask.com/web"
  style="border:3px dotted #C33;padding:6px;background-color:#FEE;" />
  <input type="text" name="q" />
  <input type="submit" value="search ask.com" />
</form>

Which looks like this:

Try it if you'd like. It works!



Help others find this article at Del.icio.us, Digg, Netscape, Reddit, and Stumble Upon    

Subscribe!

Never miss another useful Q&A article again! Subscribe to AskDaveTaylor with Google Reader.

Comments

delete ask.com from my facepage

Posted by: david carder at October 16, 2009 4:25 PM

I want part time online form fill up jobs at home. Thank you.

Posted by: Saju Dey at October 21, 2009 10:52 AM

I have something to say, now that you mention it, but ...
Starbucks coffee cup I do have a lot to say, and questions of my own for that matter, but first I'd like to say thank you for all your efforts on this Web site by buying you a cup of coffee!

I do have a comment, now that you mention it!











Remember personal info?


Please note that I will never send you any unsolicited commercial email. Ever.

While I'm at it, please note that by submitting a question or comment you're agreeing to my terms of service, which are: you relinquish any subsequent rights of ownership to your material by submitting it on this site.








Ask Dave Taylor: The iPhone App: Advertisement


Uniblue: Get A Free Virus Scan!

Follow me on Twitter @DaveTaylor

Search
Find just the answers you seek from among our 2300+ free tech support articles by using our Lijit search engine.


Help!





Subscribe to
Ask Dave Taylor!

Add to Google Reader
Add to My Yahoo!
Subscribe in NewsGator Online

RDF   XML

Free Updates!
Sign up and get free weekly updates and special offers on books, seminars, workshops and more.


Recent Entries
Book Links
© 2002 - 2010 by Dave Taylor. All Rights Reserved.

Note: This web site is for the purpose of disseminating information for educational purposes, free of charge, for the benefit of all visitors. We take great care to provide quality information. However, we do not guarantee, and accept no legal liability whatsoever arising from or connected to, the accuracy, reliability, currency or completeness of any material contained on this web site or on any linked site.

[whiteboard marker tray]
"Ask Dave Taylor®" is a registered trademark of Intuitive Systems, LLC.