Einzelnen Beitrag anzeigen

Benutzerbild von 3_of_8
3_of_8

Registriert seit: 22. Mär 2005
Ort: Dingolfing
4.129 Beiträge
 
Turbo Delphi für Win32
 
#2

Re: get outter HTML from selected text

  Alt 16. Jan 2007, 17:01
I guess you're talking about JavaScript.

In JavaScript, there are several possibilities, depending on the specific browser.

The Mozilla/Firefox solution looks like this:
Code:
    var selstart=txtarea.selectionStart;
    var selend=txtarea.selectionEnd;
    if (selstart<selend) {
      selection=txtarea.value.substring(selstart, selend);
    } else {
      selection="";
    }
And this seems to work in most of the other browsers:
Code:
selection=document.selection.createRange().text;
Manuel Eberl
„The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it.“
- Terry Pratchett
  Mit Zitat antworten Zitat