first_page the funky knowledge base
personal notes from way, _way_ back and maybe today

Microsoft JScript and MSHTML: The HTML Editor Application; HTA; MSDHTML

Users of AOL mail and MSN Hotmail have been enjoying the one thing that makes the Microsoft Internet Explorer Web browser necessary: the ability to edit HTML in place. This was one of the original specifications Tim Berners-Lee (http://www.w3.org/People/Berners-Lee/) demanded in a web browser and Netscape failed to deliver. Microsoft on the other hand has it lurking about but its not really recognized as a feature worth heavily marketing let alone documenting.

In fact, the opinion here is that Microsoft would rather have you know about the HTML Application (featuring HTA files) before you learn about the MSDHTML (JScript) behind HTML Editing. This appears to be the case in MSDN's "How to Create an HTML Editor Application":

http://msdn.microsoft.com/
    library/default.asp?
        Url=/workshop/author/editing/tutorials/html_editor.asp

I am sure there must be a better article, but theAngrycodeR (Sameers) did a great job showing off MSHTML editing in "Creating an HTML Area Server Side Control" at:

http://www.codeproject.com/aspnet/text_area_control.asp

The editor content is explained within the context of .NET server controls but just download the source code and dig out the file ...\\demo_RTFBox\\HTMLArea.html.

The key to all of this HTML editing stuff is the execCommand() method of the window.document object of MSDHTML. This is documented at MSDN:

http://msdn.microsoft.com/
    library/default.asp?
        Url=/workshop/author/dhtml/reference/methods/execcommand.asp

And the most important caveat: never forget that this editor is based on MSHTML, Microsoft's implementation of HTML which has nothing to do with the wonderful standards set by the W3C. I was forced to use a lot of complex regular expressions to parse MSHTML into "real" HTML 4.x markup.

mod date: 2003-08-26T00:49:31.000Z