Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Automate Dictionary word lookup in Firefox' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Automate Dictionary word lookup in Firefox
Authored by: tx.logic on Sep 08, '06 11:06:08AM
This is a nice hint, but it still requires that you type a URI into your browser. An earlier followup pointed out that Cntl-Cmd-d does the job automatically, but that only works in Cocoa apps (and frankly I've found it to be a bit spotty -- sometimes it works, sometimes not). If, however, you are partial to Firefox or any other non-Cocoa browser (though this will work in Cocoa browsers as well, of course), you can get almost the same functionality with a little javascript. Specifically, create a bookmark called "Dict" and for the location enter:

javascript:x=escape(getSelection());if(!x)%7Bvoid(x=prompt('What%20should%20I%20look%20up?',''))%7D;window.location='dict:///'+x
Stick that bookmark on your Firefox toolbar. Now you can call up (a running copy of) Dictionary.app for a definition of a word you come across while browsing just by highlighting it and clicking on your new bookmark. (Just clicking on the bookmark without highlighting anything will bring up a dialog box in which you can enter a word manually.)

Note the same trick can be used to call up Google for definitions. In this case, create a bookmark called "GoogleDict" (or whatever) and use the following code for the location:


javascript:x=escape(getSelection());if(!x)%7Bvoid(x=prompt('What%20should%20I%20look%20up?',''))%7D;window.location='http://www.google.com/search?query=define:'+x
More generally, you can alter this code to do a search on any site with a searching mechanism -- Wikipedia, Amazon (nice for looking up highlighted book titles or authors), whatever. Just go to the site in question, enter a search string, and use the resulting URI as the basis for revising the javascript to define the location of a new bookmark for searching that site. Just replace the specific search string you used with "x" in the javascript, as that is the variable that is carrying the string that you've highlighted.

BTW, I did not invent the basic code here. I've been using it for so long I don't remember where I found it, but it is quite likely that I saw it in a MacOSXhints hint!

[ Reply to This | # ]

Automate Dictionary word lookup in Firefox
Authored by: quangtonthat on Sep 09, '06 07:55:12AM

Your javascript does not seem to work with OmniWeb 5.5. It always comes up with a dialog box with an empty text box and I have to enter the search string (although it is already highlighted in the webpage)
.



[ Reply to This | # ]