Industry guru Dave Taylor offers tech support on technical and business topics, including iPhone, iPod, Microsoft Windows, Sony PSP, cellphones, online advertising, CSS, Web design, business, Unix, Linux, SEO, Mac OS X, and shell script programming.     


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!


More Useful HTML, JavaScript and Web Site Programming Articles:
✔   How to Create Predefined Google Image Search Links?
Thanks for the Amazon URL [see Creating Amazon Search Links]. That worked beautifully. In fact, I sent you $5.00 for coffee in thanks....
✔   Can I embed a Facebook search box on my blog site?
I've seen your articles about how to add a Twitter or Google search box on a Web page, but I have a tougher...
✔   Can I use CSS for drop shadows on my blog?
I want to give my site a bit of a facelift and add some neat graphical elements. One of which is drop shadows....
✔   How can I embed interactive photo panoramas on my site/blog?
I read through your blog entry about how to take panoramic photos with iOS 6 and an iPhone 5 and got enthused. I've...
✔   How can I create a Twitter search URL shortcut?
I'd like to add a few Twitter search links to my Web site. Is that possible, or does Twitter prohibit this sort of...

Let's stay in touch!
Sign up for my weekly AskDaveTaylor Newsletter and you'll receive even more tech and gadget help right to your inbox, along with exclusive news and industry updates. It's good stuff. I promise!
    Enter your name: and your email addr:  





Categorized: HTML, JavaScript and Web Site Programming   (Article 8736, Written by )
Tagged: ask.com, cgi, css, html, reverse engineering, search engines
Previous: How to delete your comments from a YouTube video?
Next: How do I organize a meetup?




Reader Comments To Date: 2

david carder said, on October 16, 2009 4:25 PM:

delete ask.com from my facepage

Saju Dey said, on October 21, 2009 10:52 AM:

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

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, Dave, for all your helpful information by buying you a cup of coffee!

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











I will never send you any unsolicited email. Ever.






Check This Out Too...

 
Look for Answers
Need Help? Ask Dave Taylor!


Follow Me on Pinterest

Find Me on Google+
ADT on G+
© 2002 - 2013 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. Further, 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. My lawyer says "Thanks".
"Ask Dave Taylor®" is a registered trademark of Intuitive Systems, LLC.