Can't change body background by calling setHTML()

Last post 06-12-2007, 1:26 PM by ytang. 4 replies.
Sort Posts: Previous Next
  •  06-08-2007, 6:45 PM 30530

    Can't change body background by calling setHTML()

    Hi,
     
    It is a critical issue for us because we have many functions to set contents to the editor from client-side. They were working in version 5.3 very well, but not in version 6.0.
     
    It is easy to reproduce. The following is the description of the issue:
     
    1. editor1.EditCompleteDocument = true to allow the editor to show body tag;
     
    2. Paste the following html code into the editor:
     
    <html>
         <head>
          </head>
        <body style="background-color: #3366ff">
            <p>Old Content</p>
        </body>
    </html>
     
    3. In WYSIWYG view, call the following function to set a new content to the editor to replace the old one.
     
    editor1.setHTML("<html><head></head><body><p>New Content</p></body></html>");
    or
    editor1.setHTML("<html><head></head><body style=\"background-color: #ffffff\"><p>New Content</p></body></html>");
     
    4. The result is the text has been changed to "New Content", but it still has the old background color in the body tag.
     
    5. It also happens when body tag has background-image;
     
    I found the standard "Page Properties" diaglog has no problem to change body background. Is there any way to set html content in client-side other than calling setHTML()?
     
    Thanks.
     
     
  •  06-08-2007, 9:18 PM 30534 in reply to 30530

    Re: Can't change body background by calling setHTML()

    Try the following code:
     
    // get the cute editor instance
    var editor1 = document.getElementById('<%= Editor1.ClientID%>');

    // get the active editor document
    var editdoc = editor1.GetDocument();
    editdoc.open("text/html","replace")
    editdoc.write(h);
    editdoc.close();
     
     

     


    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  06-11-2007, 5:17 PM 30600 in reply to 30534

    Re: Can't change body background by calling setHTML()

    It works. Thank you.
     
  •  06-11-2007, 8:16 PM 30608 in reply to 30534

    Re: Can't change body background by calling setHTML()

    Adam,
     
    I just found a new issue that caused by the method you provided. Afer executing the following code, the background changed. But, if I click a submit button to post back the form immediately without doing any action on the editor (e.g. switch view), the Editor1.Text returns the old content.
     
    var editor1 = document.getElementById('<%= Editor1.ClientID%>');
    var editdoc = editor1.GetDocument();
    editdoc.open("text/html","replace")
    editdoc.write(h);
    editdoc.close();
    I guess the editor must has an internal variable to tell if the text is changed. The function setHTML() can set the variable but above code can't. Could you please tell me how to set the variable to let the editor know the text is changed?
     
    Currently, my workaround is to call setHTML(h) after executing the code above. It works, but doesn't sounds good.
     
     
  •  06-12-2007, 1:26 PM 30637 in reply to 30608

    Re: Can't change body background by calling setHTML()

    Adam, any ideas about the postback issue that I described yesterday?
     
View as RSS news feed in XML