Re: How can I dynamically set the EditorBodyStyle from JavaScript?

  •  07-30-2013, 1:31 PM

    Re: How can I dynamically set the EditorBodyStyle from JavaScript?

    Hi gll1559,

     

    Please try the new example below, it should work.

     

    1. <%@ Page Language="c#" ValidateRequest="false" %>    
    2.     
    3. <%@ Register TagPrefix="RTE" Namespace="RTE" Assembly="RichTextEditor" %>    
    4. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">    
    5. <html xmlns="http://www.w3.org/1999/xhtml">    
    6. <head>    
    7.     <title>example</title>    
    8. </head>    
    9.     
    10. <body>    
    11.     <form id="Form1" method="post" runat="server">    
    12.         <RTE:Editor ID="editor1" runat="server"  />    
    13.     <input type="button" value="change editor body style"  onclick="styleChange()"/>    
    14.     <script type="text/javascript">  
    15.        
    16.         function styleChange() {  
    17.             // get the rich text editor instance    
    18.             var editor1 = document.getElementById('<%= editor1.ClientID%>').editor;  
    19.             // get the active editor document    
    20.             var editwin = editor1.GetWindow();  
    21.             var editdoc = editwin.document;  
    22.             //change the editor body style in javascript    
    23.             editdoc.body.style.backgroundColor = "red";  
    24.         }  
    25.         function RichTextEditor_OnExecCommand(editor, arg) {  
    26.             var a0 = arg.Arguments[0];  
    27.             if (a0 == "Undo")  
    28.             {  
    29.                 setTimeout("styleChange()", 1);  
    30.             }  
    31.         }  
    32.     </script>    
    33.     </form>    
    34. </body>    
    35. </html>    
     

    Regards,

     

    Ken 

View Complete Thread