Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Netzwerke (https://www.delphipraxis.net/14-netzwerke/)
-   -   Delphi get outter HTML from selected text (https://www.delphipraxis.net/84415-get-outter-html-selected-text.html)

mr_fahrrad 16. Jan 2007 16:57


get outter HTML from selected text
 
How i make to get the outer html from selected text?

example

<font color="#123456"> example text, this is selected, bla bla bla</font>

the text 'this is selected' is selected, so i get the outer text (the full line above

how i make this?

3_of_8 16. Jan 2007 17:01

Re: get outter HTML from selected text
 
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;


Alle Zeitangaben in WEZ +1. Es ist jetzt 14:48 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz