Slashdot Mirror


AJAX Inline Dictionary like WallStreetJournal.com

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. "

5 of 52 comments (clear)

  1. Re:stop that! by red_dragon · · Score: 2, 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.

    --
    In Soviet Russia, Jesus asks: "What Would You Do?"
  2. Re:I'm bored, so I checked.... by magores · · Score: 3, Informative

    Sorry for replying to myself, but I forgot to mention, that I DO like this idea.

    It's kinda like what they do at http://newsinchinese.com/ And, sorta like the firefox extension from http://www.asdotrans.com/.

    I could see myself using a modified version of this.

    --
    The negative tone of my parent post was unintentional

  3. browser compatibility by peesharp · · Score: 2, Informative

    It does not work with Opera (9).

    1. Re:browser compatibility by spectral · · Score: 2, Informative

      I don't think that it's because Opera is better or nicer (though I'm sure I could disable it if it did work), I think it's because, for some reason, people are STILL doing browser detection like idiots. Not that I mind, I can't stand the idea of this (leave right click alone!)

      The problem?
      // -- Browser Detection --
      var ie = document.all&&document.getElementById
      var ff = document.getElementById&&!document.all // If the browser is compatible on right-click call the function to get the highlighted text
      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.)

  4. Dict Greasemonkey script by nitro322 · · Score: 3, Informative

    Any Firefox/Greasemonkey users out there that are interested in this may also want to check out the Dict script: http://userscripts.org/scripts/show/1467

    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 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.