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>

  • 相关阅读:
    输出乘数
    输出三角形---编程小记,跟答案不一样但是效果一样,自己动脑子想的,开心
    python collection
    python 之购物车
    python之计算器
    python学习笔记
    724.中心索引
    495.提莫队长
    342.4的幂
    657.机器人能否返回原点
  • 原文地址:https://www.cnblogs.com/dearxinli/p/2825262.html
Copyright © 2011-2022 走看看