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.
views:
887answers:
2
+4
A:
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
desmati
2009-08-25 10:51:59
let us know if works on any other browser
desmati
2009-08-25 10:54:03
I'll give it a go later today... yeah, I dont stop by that often, sorry.
Kristoffer S Hansen
2009-09-18 07:36:12
Worked just fine, thankyou
Kristoffer S Hansen
2009-10-02 09:51:00
Your welcome, if this my post was your answer, please mark it and let others know that.
desmati
2010-04-27 20:37:16
@desmati why do you try the styleWithCSS twice, once with 0 and once with false? Won't 0 cast to false?
thomasrutter
2010-10-26 06:34:04
A:
(This comment is directly related to desmati's response to original question. I have the same issue original poster had, and the provided solution does not seem to work for me. Please read comments before you vote them down.)
Could anyone tell me why this does not work in Chrome, please? Ctrl+B creates <b> instead of <span> with style-attribute.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>styleWithCSS in Chrome</title>
<script type="text/javascript">
function onLoad()
{
document.body.contentEditable = true;
document.execCommand("styleWithCSS", false, true);
}
</script>
</head>
<body onload="onLoad();">
</body>
</html>
Jaroslav Záruba
2010-04-17 15:06:57
If you have a question, please ask a question. Don't "answer" someone else's question.
David Dorward
2010-04-17 15:26:36
If you actually read my comment you would notice that my comment is the same issue original poster was asking about. The solution provided by desmati does not seem to work for me, it is directly related to his response. If I could post directly under his comment I would certainly do so.Thank you for voting my comment down without even reading it. :(
Jaroslav Záruba
2010-04-25 13:13:44