Search code examples
javascriptinternet-explorerwysiwygrte

styleWithCSS for IE


I'm building a custom RTE that converts user input to a homebrewn markup, now idiot that I am I did this using an iframe with designMode = "On" and got it to work in firefox using styleWithCSS = false so that I could easily convert the <b> (yes... b :( ) into my markup which would then output the proper code instead of me having to read from <span style="... now my problem is, I cant seem to find something that looks or acts like styleWithCSS = false for IE, Chrome or Opera, any suggestions are welcome.


Solution

  • Use this:

                try {
                    Editor.execCommand("styleWithCSS", 0, false);
                } catch (e) {
                    try {
                        Editor.execCommand("useCSS", 0, true);
                    } catch (e) {
                        try {
                            Editor.execCommand('styleWithCSS', false, false);
                        }
                        catch (e) {
                        }
                    }
                }
    

    Before any other execCommands. Tested on ff3 ie7 ie8 safari chrome