Re: javascript cleanuphtml and count number of characters

  •  08-31-2010, 8:44 PM

    Re: javascript cleanuphtml and count number of characters

    Hi surrounding,
     
    1. Clean up HTML example
     
    1. <%@ Page Language="C#" %>   
    2.   
    3. <%@ Register Assembly="CuteEditor" Namespace="CuteEditor" TagPrefix="CE" %>   
    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 id="Head1" runat="server">   
    7.     <title>GetPlainText</title>   
    8. </head>   
    9. <body>   
    10.     <form id="form1" runat="server">   
    11.         <CE:Editor ID="editor1" runat="server">   
    12.         </CE:Editor>   
    13.         <input type="button" value="Clean THML" onclick="cleanTHML()" />   
    14.         <div id="plainText" style="visibility: hidden">   
    15.         </div>   
    16.     </form>   
    17. </body>   
    18. </html>   
    19.   
    20. <script>   
    21. function cleanTHML()   
    22. {   
    23.     var editor1=document.getElementById('<%= editor1.ClientID %>');   
    24.     var plainText=document.getElementById("plainText");   
    25.     plainText.innerHTML=editor1.GetHTML();   
    26.     editor1.SetHTML(plainText.innerText)   
    27.     plainText.innerHTML="";   
    28. }   
    29.   
    30. </script>  
    2. Check the length of the editor text example
     
    1. <%@ Page Language="C#" %>   
    2.   
    3. <%@ Register Assembly="CuteEditor" Namespace="CuteEditor" TagPrefix="CE" %>   
    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 id="Head1" runat="server">   
    7.     <title>GetPlainText</title>   
    8. </head>   
    9. <body>   
    10.     <form id="form1" runat="server">   
    11.         <CE:Editor ID="editor1" runat="server">   
    12.         </CE:Editor>   
    13.         <input type="button" value="Check length" onclick="checkLength()" />   
    14.           </form>   
    15. </body>   
    16. </html>   
    17.   
    18. <script>   
    19. function checkLength()   
    20. {   
    21.     var editor1=document.getElementById('<%= editor1.ClientID %>');   
    22.     alert(editor1.getHTML().length)   
    23. }   
    24. </script>  
    Regards,
     
    ken
View Complete Thread