[Project_owners] Editor content

Michael Buckley michael.buckley at hotmail.com
Mon Sep 11 13:23:29 EDT 2006

Thanks that is what I needed, though it put out \n\r were it should only
be \n  if you understand what I mean.  Easy enough to fix.  Here is what
my script looks like.

   var editor = document.getElementById('myEditor');

  var oldStr =
editor.getEditor(editor.contentWindow).outputToString("text/plain", 0);
    var findStr = '\n\r';
    var repStr = '';

    var srchNdx = 0;
    var newStr = '';
    while (oldStr.indexOf(findStr,srchNdx) != -1) {
        newStr  = oldStr.substring(srchNdx,oldStr.indexOf(findStr,srchNdx));
        newStr  = repStr;
        srchNdx = (oldStr.indexOf(findStr,srchNdx)   findStr.length   1);
    newStr  = oldStr.substring(srchNdx,oldStr.length);

newStr being the text.

Neil wrote:
>Michael Buckley wrote:
>>But my problem is getting the text out of the editor.  doc.textContent 
>>returns all the text with out the line breaks.  doc.innerHTML returns all 
>>the br tags and all the <> converted to &lt; &gt; and no line breaks.  So 
>>how can this be done?  Thunder Bird appears to be able to do this when a 
>>message is set a plain text so it must be possible.
>TB probably uses its own serializer but I think you'll find that 
>editor.outputToString can do what you want. The flags are defined on 
>nsIDocumentEncoder on the trunk but it will work with earlier versions if 
>you substitute the literal values.
>Project_owners mailing list
>Project_owners at mozdev.org

Research and compare new cars side by side at carpoint.com.au 

More information about the Project_owners mailing list