SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2005
    Posts
    81
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Rich Text Editor

    Hi,

    I'm making a rich text editor and I have a few questions about it.
    1) IE and Firefox use an iframe in design mode for the contents. What are the alternatives that Netscape, Konqueror, etc use?
    2) IE and Firefox use execCommand (I'm not sure if others do). How would I go about making a function that acts similar, e.g. inserts html where the cursor is or if text is selected, wraps the text with html (i.e. text is "text", if the cursor is between x and t it becomes 'tex[tag]t', but if "text" is selected, it becomes "[tag]text[/tag]")?
    3) How do you use execCommand with firefox? With IE, i use
    Code:
    document.getElementById('rte').contentWindow.document.execCommand("bold",false);
    to change text to bold, but this does not work with firefox.

    Thanks for your help!

  2. #2
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    1) As far as I know, Konqueror does not support that. I'm fairly sure that code for that written for Firefox will work in Netscape 7.1+.

    2) http://www.alexking.org/blog/2003/06...ng-javascript/
    http://www.massless.org/mozedit/
    http://parentnode.org/javascript/wor...rsor-position/

    3) The first argument of execCommand() does not seem to be case sensitive.
    In Mozilla it only works if the document is set as content editable.
    Mozilla seems to require all 3 arguments.

    http://msdn.microsoft.com/workshop/a...xeccommand.asp
    http://www.mozilla.org/editor/midas-spec.html
    http://www.dotvoid.com/view.php?id=11
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.

  3. #3
    SitePoint Enthusiast
    Join Date
    Dec 2005
    Posts
    81
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Kravvitz, thats exactly what I needed.
    1) Netscape does support it although appears to right click randomly in the ifarme for some odd reason
    2) Good info, couldn't get them working in an iframe though.
    3) Making the last parameter null seemed to fix the problem with Firefox.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •