HtmlEditor :  Phorum 5 The fastest message board... ever.

This is the discussion forum for the HtmlEditor. See also the HtmlEditor home page, where you can download the control, and the Documentation Wiki, a collaborative project for documenting the control.

Goto Thread: PreviousNext
Goto: Forum ListMessage ListNew TopicSearchLog In
Selecting a single word
Posted by: (62.48.170.---)
Date: Monday, 21-Apr-2003, 18:01:38

Hi,

Im trying to apply a style to a word I select on the editor. But what I get when I use CurrentElement.innerText, for instance, is the entire text content between any two tags. Is there any way to retrieve only the selected word in order to apply the style only to it?

Thanks in advance

Re: Selecting a single word
Posted by: Tim Anderson (---.server.ntl.com)
Date: Monday, 21-Apr-2003, 18:13:14

Yes, you can get the innerHtml, replace the selected text with the selected text plus the tags you want to add, and then write it back to the element. In other words, work with the innerHtml as a string.

Tim

Re: Selecting a single word
Posted by: (62.48.170.---)
Date: Monday, 21-Apr-2003, 18:39:46

I never expected such a quick response smiling smiley thanks.

But what I'm trying to do is the following:

If I write "Hello world" and I get the innerHtml I'll get the entire string ("Hello world"), but by selecting "world" and applying the style, the result i'd like to get is:

"Hello <span class='.Title'>world</span>".

Maybe I'm not getting just what you mean with "selected text"... I tried inneHtml but I get what's between <body> and </body>.

Thanks in advance.

Re: Selecting a single word
Posted by: (62.48.170.---)
Date: Monday, 21-Apr-2003, 18:48:38

Well... I think I found it...

Dim s As mshtml.IHTMLTxtRange
s = htmlEditor1.Document.selection.createRange()
MsgBox(s.htmlText)

This gets the selected word... I'll see what I can do with it.



Your Name: 
Your Email: 
Subject: 
Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically.
pkWjb
This is a moderated forum. Your message will remain hidden until it has been approved by a moderator or administrator
This forum powered by Phorum.