js hookup warnings when the content has been changed

Last post 03-21-2010, 9:05 PM by Kenneth. 1 replies.
Sort Posts: Previous Next
  •  03-21-2010, 6:26 PM 59538

    js hookup warnings when the content has been changed

    I'm developing a mdoule that every time when the content of cute editor has been changed, before the user navigates away from the page without clicking on save button, they system will popup a warning message by js.
    I use the function "CuteEditor_OnChange(editor)". It seems to work ok. But it's every slow although I run everything on my local development environment.
    Is that any other more efficient way to achieve this? Thx

     
  •  03-21-2010, 9:05 PM 59539 in reply to 59538

    Re: js hookup warnings when the content has been changed

    Hi wolf11th,
     
    Try the example below
    1. <%@ Page Language="C#" %>   
    2.   
    3. <%@ Register TagPrefix="CE" Namespace="CuteEditor" Assembly="CuteEditor" %>   
    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>example</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" onclick="check()" /><br />   
    14.         click on the button, if you changed the text, it will show a message.   
    15.         <asp:Label ID="label1" runat="server" Style="visibility: hidden"></asp:Label>   
    16.     </form>   
    17. </body>   
    18. </html>   
    19.   
    20. <script type="text/javascript">   
    21.   
    22. var editor1=document.getElementById("<%= editor1.ClientID %>");   
    23. var label1=document.getElementById("<%= label1.ClientID %>");   
    24. function CuteEditor_OnInitialized(editor)   
    25. {   
    26. editor.SetHTML("this is a test");   
    27. label1.innerHTML=editor1.getHTML();   
    28. }   
    29. function check()   
    30. {   
    31.   
    32. var str1=label1.innerHTML.toLowerCase();   
    33. var str2=editor1.getHTML().toLowerCase();   
    34.   
    35. if(!(str1.indexOf(str2)==0 && str2.indexOf(str1)==0))   
    36. {   
    37.     alert("text have been changed");   
    38. }   
    39. }   
    40. </script>  
    Regards,
     
    Ken
View as RSS news feed in XML