removing span tags

Last post 03-23-2010, 10:38 PM by Kenneth. 1 replies.
Sort Posts: Previous Next
  •  03-23-2010, 7:30 PM 59606

    removing span tags

    I would like to remove all span tags from the editor text.  I added this to the bottom of the aspx page:
     
    <script type="text/javascript" language="javascript">
    function CuteEditor_FilterHTML(editor,code)
    {
    return code.replace(/(<span[^\>]*\>)([\s\S]*)(\<\/span\>)/i, "$2");
    }
    function CuteEditor_FilterCode(editor,code)
    {
    return code.replace(/(<span[^\>]*\>)([\s\S]*)(\<\/span\>)/i, "$2");
    }
    </script>
     
     I entered this text in HTML mode:
    <span>a</span><span>b</span>
     
    After switching to Normal and back to HTML it shows:
    a</span>b
     
    Why is the </span> there?
     
    Thanks
  •  03-23-2010, 10:38 PM 59610 in reply to 59606

    Re: removing span tags

    Hi mushroom,
     
    Try
     
    1. <script>   
    2. function CuteEditor_FilterHTML(editor,code)   
    3. {   
    4.  return code.replace(/(<span[^\>]*\>)((\n|\r|.)*?)(?:<\/span>)/i, "$2");   
    5. }   
    6. function CuteEditor_FilterCode(editor,code)   
    7. {   
    8. return code.replace(/(<span[^\>]*\>)((\n|\r|.)*?)(?:<\/span>)/i, "$2");   
    9. }   
    10. </script>  
    Regards,
     
    ken
View as RSS news feed in XML