Hello,
I have a problem when setting html with setHTML function. I'm trying to set an entire xhtml document (html, meta, style, etc. tags included) and I get the problem that the editor seems to protect itself from this kind of source.
The JS code to do this is:
function transferData(iframe) { // Get the editor instance that we want to interact with. var oEditor = FCKeditorAPI.GetInstance('myeditor') ; try { // Set the editor contents (replace the actual one). oEditor.SetHTML(iframe.contentWindow.document.documentElement.innerHTML); //oEditor.EditorDocument.body.innerHTML = iframe.contentWindow.document.documentElement.innerHTML; } catch(e) { alert(e); } }
For instance, if I send this code:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/tr/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252" /> <style type="text/css"> /* Style Definitions */ p, li, div {margin:0; margin-bottom:.0001pt; font-size:12.0pt; text-align:justify; font-family:Arial,sans-serif;} </style> </head> <body lang="ES"> <div class="Section1"> ...
I will get:
<p> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252" /> <style type="text/css"> /* Style Definitions */ p, li, div {margin:0; margin-bottom:.0001pt; font-size:12.0pt; text-align:justify; font-family:Arial,sans-serif;} </style> </p>
¿Does anybody know why the editor encapsulates the styles into a paragraph tag?
I can upgrade to 2.5.1 and try it with setData if it solves, but I'm preparing a demo and I would prefer to upgrade after it.
Thanks in advance.
Re: Problem when setting html