zoukankan      html  css  js  c++  java
  • 包含清除word中的样式的过滤

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>

    </head>

    <body>
     <div id="test" style="float: left; height: 100px; 500px; border:1px solid red" contenteditable="true" class="testmr"> 2222</div>

    </body>

    </html>
    <script type="text/javascript" src="js/jquery.js"></script>
    <script type="text/javascript">
    $(function(){

    var updates = function(){
        
        $('.testmr).each(function(){
           
               if($(this).find('img').length>0){
           
             $(this).find('img').each(function(){
                    
                 if($(this).attr('src').toString().substr(0,44)=='http://res1.starheld.com:8080/group2/M00/0B/'){
              
               return;
              
             }else{
              
              $(this).remove();
              
             }
             
             })
            
             }
           
              if($(this).find('input').length>0){
           
             $(this).find('input').each(function(){
                     
                 if($(this).attr('class')=='fill_empty'){
              
               return;
              
             }else{
              
              $(this).remove();
              
             }
             
             })
            
             }
          
            var new_content = $(this).html();
           
           
            var reg_list = [/<\/?[wm]:([^>]+)\/?>([^<]+<\/[wm]:\1>)?/ig, /<(style)>[^<]+<\/\1>/ig, /<(?!img|input)[^>]+>/ig];
            $.each(reg_list, function(i, reg){
            new_content = new_content.replace(reg, '');     
            });
           
          $(this).html(new_content);
          
          
         })
         } 
        
          
      $('.testmr).bind('paste',function(){
          
          setTimeout(function(){updates();}, 10);      
                
        })

      })

    </script>

  • 相关阅读:
    使用 Spring data redis 结合 Spring cache 缓存数据配置
    Spring Web Flow 笔记
    Linux 定时实行一次任务命令
    css js 优化工具
    arch Failed to load module "intel"
    go 冒泡排序
    go (break goto continue)
    VirtualBox,Kernel driver not installed (rc=-1908)
    go运算符
    go iota
  • 原文地址:https://www.cnblogs.com/dearxinli/p/2825262.html
Copyright © 2011-2022 走看看