src/lay/modules/layedit.js
function(tagName, attr, range){
    var iframeDOM = this.document
    ,elem = document.createElement(tagName)
    for(var key in attr){
      elem.setAttribute(key, attr[key]);
    }
    elem.removeAttribute('text');

    if(iframeDOM.selection){ //IE
      var text = range.text || attr.text;
      if(tagName === 'a' && !text) return;
      if(text){
        elem.innerHTML = text;
      }
      range.pasteHTML($(elem).prop('outerHTML')); 
      range.select();
    } else { //非IE
      var text = range.toString() || attr.text;
      if(tagName === 'a' && !text) return;
      if(text){
        elem.innerHTML = text;
      }
      range.deleteContents();
      range.insertNode(elem);
    }
  }
function(tagName, attr, range){
    var iframeDOM = this.document
    ,elem = document.createElement(tagName)
    for(var key in attr){
      elem.setAttribute(key, attr[key]);
    }
    elem.removeAttribute('text');

    if(iframeDOM.selection){ //IE
      var text = range.text || attr.text;
      if(tagName === 'a' && !text) return;
      if(text){
        elem.innerHTML = text;
      }
      range.pasteHTML($(elem).prop('outerHTML')); 
      range.select();
    } else { //非IE
      var text = range.toString() || attr.text;
      if(tagName === 'a' && !text) return;
      if(text){
        elem.innerHTML = text;
      }
      range.deleteContents();
      range.insertNode(elem);
    }
  }
function ( tagName , attr , range ) { var iframeDOM = this . document , elem = document . createElement ( tagName ) for ( var key in attr ) { elem . setAttribute ( key , attr [ key ] ) ; } elem . removeAttribute ( 'text' ) ; if ( iframeDOM . selection ) { //IE var text = range . text || attr . text ; if ( tagName === 'a' && ! text ) return ; if ( text ) { elem . innerHTML = text ; } range . pasteHTML ( $ ( elem ) . prop ( 'outerHTML' ) ) ; range . select ( ) ; } else { //非IE var text = range . toString ( ) || attr . text ; if ( tagName === 'a' && ! text ) return ; if ( text ) { elem . innerHTML = text ; } range . deleteContents ( ) ; range . insertNode ( elem ) ; } }
iframe初始化
iframe初始化