AJAX Inline Dictionary like WallStreetJournal.com 52
chevoldavis writes "Highlight any text on this site then right click. A tooltip containing the definition of the selected word should show up. This tutorial will show you how to accomplish this, step by step. You can modify it to call any function or webservice. This is similar to the WallStreetJournal.com except they show search results in their tooltip window and they leave the functionality of the context menu while I have chosen to supress it.
"
Re:stop that! (Score:3, Informative)
So you're still using Internet Explorer, then?
I've just tried it with Firefox, which can optionally prevent JavaScript code from disabling context menus, and the usual right-click menu appeared with the AJAX-generated tooltip beneath it.
Re:I'm bored, so I checked.... (Score:3, Informative)
It's kinda like what they do at http://newsinchinese.com/ [newsinchinese.com] And, sorta like the firefox extension from http://www.asdotrans.com/ [asdotrans.com].
I could see myself using a modified version of this.
--
The negative tone of my parent post was unintentional
browser compatibility (Score:2, Informative)
Re:browser compatibility (Score:3, Informative)
The problem?
var ie = document.all&&document.getElementById
var ff = document.getElementById&&!document.all
if (ie||ff)
{
document.oncontextmenu = getselection;
}
opera supports "document.all" AND "getElementById". (hell, firefox does too, it just refuses to let you check for document.all so as to NOT break stupidities like this.)
Dict Greasemonkey script (Score:3, Informative)
It adds a similar, but much less intrusive capability. Simply double-click on any word to highlight it, and the definition is shown in a small window. Once you're done, just click the X (or use my own slgihtly-modified version [legroom.net] and click anywhere on the page) to close it.
Of course, this has both it's pros and cons as compared to the original idea discussed in the story. Since it's a client-side solution, this isn't something that will be available to your visitors. However, the good news is that it doesn't hijack your browser's context menu, which, as mnay other people have commented, is something I personally despise.