Re: Getting Selected Text
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.javascript archive

Re: Getting Selected Text

From: afrinspray <afrinspray@gmail.com>
Date: Tue Mar 28 2006 - 01:18:24 CEST

I didn't want to set the text of an element, but your function gave me
the window.getSelection() function to lead me in the right direction.
This function doesn't work for me in IE, so I made this function
below... it seems to work alright.

function getSelectedText() {

    if(window.getSelection) {
        return window.getSelection();
    }
    else if(document.selection.createRange().text) {
        return document.selection.createRange().text;
    }
                                        
    return '';
                                        
}
Received on Mon May 1 04:27:59 2006