fck 的写入删除特定text的js ff ie7测试通过

来源:互联网 发布:赛诺数据中国手机9月 编辑:程序博客网 时间:2024/06/04 18:20
为了实现用js 写入特定text 和删除特定text 
  1. function trim(str){   
  2. return str.replace(/^/s+|/s+$/g, "");   
  3. }   
  4. function usePreMsg(o){ //应用预置编辑信息hgx20070124   
  5.  var _iframe = document.getElementById ("content___Frame").contentWindow.document;   
  6.     var win = _iframe.getElementsByTagName("iframe")[0].contentWindow;   
  7.     var doc = win.document;   
  8.     doc.getElementsByTagName("body")[0].focus();   
  9.     var tagp;   
  10.        
  11.     if(o.checked){   
  12.         try{tagp=doc.getElementsByTagName("body")[0].getElementsByTagName("p"); doc.execCommand("insertHTML",false"<p style=/"margin:0;font-size:12px;/" id=/""+o.id+"/">● "+o.value+":</p>"); }   
  13.         catch(e){   
  14.        
  15.          var _html = doc.selection.createRange();   
  16.         _html.pasteHTML("<p style=/"margin:0;font-size:12px;/" id=/""+o.id+"/">● "+o.value+":</p>");   
  17.            
  18.         return false;}   
  19.         var i,ishas=false;   
  20.         for(i=0;i<tagp.length;i++){   
  21.             if(o.id==tagp[i].id){ishas=true;break;}   
  22.         }   
  23.         if(!ishas){_html.pasteHTML( "<p style=/"margin:0;font-size:12px;/" id=/""+o.id+"/">● "+o.value+":</p>");}   
  24.     }   
  25.     else{   
  26.         try{doc.body.removeChild(doc.getElementById(o.id));}   
  27.         catch(e){return false;}   
  28.     }   
  29. }//相关诊室提取控制函数hgx20060906   
  30.   
  31.   
  32. function doc() {   
  33.     var _iframe = document.getElementById ("content___Frame").contentWindow.document;   
  34.     var win = _iframe.getElementsByTagName("iframe")[0].contentWindow;   
  35.     var doc = win.document;   
  36.     return doc;   
  37.     }  
 
原创粉丝点击