scriptygoddess

17 Jun, 2003

Javascript: Select text on a page and search in google

Posted by: Jennifer In: Bookmarks

There are a few demonstrations out there of how to invoke a search on the current text selection.

This is a stab at doing it in a non-intrusive way.

5 Responses to "Javascript: Select text on a page and search in google"

1 | Doc

June 17th, 2003 at 6:07 pm

Avatar

That is a really great little code snippet. Probably one of the most useful I've used! I wrapped it up in a .js file and included it.

One question I have is that on my site for some reason in Mozilla Browsers the little G is locked into the upper left hand corner and I can't seem to unlock it.

2 | Lloyd Dalton

June 17th, 2003 at 7:19 pm

Avatar

Thanks for creating the .js. The custom formatting looks nice too. The positioning issue has something to do with the loose.dtd in your DOCTYPE:

< !DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">

Switch the doctype to:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

and watch the problem disappear :)

I have to plead ignorance about exactly why the doctype causes the absolute positioning to not work. But switching doctypes shouldn't cost you anything–the page doesn't validate anyway :)

3 | huphtur

June 18th, 2003 at 10:01 am

Avatar

firebird has this standard under the right mouse button

4 | Lloyd Dalton

June 18th, 2003 at 10:22 am

Avatar

Hey, you're right!

It took me a few minutes to figure out your comment. For anyone who's still scratching their head–in Firebird, if you select some text and then right-click on the selection, one of the menu options is "Web search for 'ABC'" where ABC is your selection.

Dang, all that work for nothing :)

5 | Doc

June 18th, 2003 at 3:31 pm

Avatar

LOL! You would tell me to change my DOCTYPE..

I lust added the loose.dtd to get the darned thing to validate!

Even if Firebird does have this option, IE doesn't, not to mention the pure "cool factor!" :)

Thanks again.

Did you grab the .js??

Featured Sponsors

Genesis Framework for WordPress

Advertise Here


  • Scott: Just moved changed the site URL as WP's installed in a subfolder. Cookie clearance worked for me. Thanks!
  • Stephen Lareau: Hi great blog thanks. Just thought I would add that it helps to put target = like this:1-800-555-1212 and
  • Cord Blomquist: Jennifer, you may want to check out tp2wp.com, a new service my company just launched that converts TypePad and Movable Type export files into WordPre

About


Advertisements