SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    $books++ == true matsko's Avatar
    Join Date
    Sep 2004
    Location
    Toronto
    Posts
    795
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Browser Differences and the Exec Command

    I just reciently hand coded from scratch a rich text editor application. It uses an iframe and communicates with a selection based exectution method.

    document.getElementById('iframe').contentWindow.document.execCommand()

    This code is what I use to manipulate a selection, to add style tags, or to insert images into the iframe. There is no problem with the functionality, however the only thing that seems to bother me is that:

    IE uses the old style tags like <B>,<EM>,<U> to stylize the given effects (not to mention they are all uppercase)

    Firefox uses a more respectable way of styling, it uses span elements in conjunction with inline styles to represent the styles (bold, italics, underlined, etc...).

    I highly doubt that internet explorer 7 has improved on this coding feature at all, needless to say that they will, but on the server end it is downright annoying to have to distinquish between the old and new html.

    The general idea is for the server code (PHP) to validate the richtext area inputted text. When the text is submitted to the server and is fetched with the $_POST array, then the PHP must basically change the poor IE html markup to the more modern FireFox style markup (or something similar, no styles but only class' => <span class="bold">...</span>).

    So aside for the php method, of changing the markup, is there a solution on the client side?
    I can't believe I ate the whole thing

  2. #2
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is there a solution on the client side?
    Sure. You can do the same text replacement with js that you are doing with php, but what's the point? js solutions are typically used to avoid having to make a round trip to the server, but you are going to make that journey anyway.

  3. #3
    $books++ == true matsko's Avatar
    Join Date
    Sep 2004
    Location
    Toronto
    Posts
    795
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    True. You can't depend only on client side validation...
    I can't believe I ate the whole thing

  4. #4
    SitePoint Zealot
    Join Date
    Jul 2006
    Posts
    151
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What's the document type, does changing this have any effect?

    Dave

  5. #5
    $books++ == true matsko's Avatar
    Join Date
    Sep 2004
    Location
    Toronto
    Posts
    795
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The document type was xhtml transitional, but when changed to strict then the only thing that changes is the bold style, from <B> to <STRONG>

    I replaced the document type in both the main document and the iframe, but still got the same result.
    I can't believe I ate the whole thing

  6. #6
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    True. You can't depend only on client side validation...
    Huh? What's client side validation have to do with anything?


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
  •