On Tue, Jun 30, 2009 at 12:31, Alexander<alexanderf...@gmail.com> wrote:
> I am trying to detect the DOM element on a unkown web page  from the
> current selected text on that page.
>
> Which means: I select text on a web page and then I would like to get
> the dom element to which this text belongs.

This is not a jQuery-specific topic, it's pure JavaScript / DOM management.
You need to use the W3C DOM selection API / IE DOM selection API to do that.

In particular, you need to differentiate between the standard W3C
implementation and the non-standard IE implementation:

if (typeof window.getSelection === 'function') {
        // W3C DOM selection API available :)
} else {
        if (typeof window.selection === 'object') {
                // IE selection API available :|
        } else {
                // No selection API available :(
        }
}

Be sure to read:
https://developer.mozilla.org/en/DOM/Selection
http://msdn.microsoft.com/en-us/library/ms535869.aspx
-- 
Massimo Lombardo
Linux user #437712

Reply via email to