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

  •  07-26-2013, 8:26 PM

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

    Hi gll1559,

     

    Please try the example below, it shows you how to change the editor body style dynamically in javascript code.

     

    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.         function styleChange()  
    16.         {  
    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.     </script>  
    26.     </form>  
    27. </body>  
    28. </html>  
     

    Regards,

     

    Ken 

View Complete Thread