Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

Stylesheets for MS DHTML Editing Component

8:55 am on Jul 30, 2002 (gmt 0)

New User

10+ Year Member

joined:June 16, 2002
votes: 0

I want to implement my own stylesheets in the MS DHTML Editing Active-X control. Does any one know hoe to do this?



1:00 pm on July 31, 2002 (gmt 0)

Inactive Member
Account Expired


Your question could have done with a bit more detail!

For a start the DHTML control is deprecated and I have been using the a DIV with CONTENTEDITABLE enabled (not sure what the MS jargon for this is but it is the replacement to the DHTML editing control)

It automatically respects any styles defined in the page containing it.

As for allowing the user to apply styles to their input I used something like this (Javascript):

function strapline()
cursorPos.execCommand("formatblock",false, "<p>")
var el = cursorPos.parentElement();
el.className = "strapline";

cursorPos is set by a function called on keydown and mousedown in the DIV which does:

after making sure the selection is of type 'text'. If it is type 'control' it does:
el = document.selection.createRange();
cursorPos= el(0);

It only seems to format whole paragraphs even if you select sub-blocks. I don't know what other formats other than <p> that the execCommand("formatblock") accepts and can't find anything on MSDN...

I have also tried this:

function anystyle(mystyle)
cursorPos.className = mystyle;

I also played with something like this:


but you need to get an element into el first...