html editor learning

Original link: http://www.cnblogs.com/flex_fly/archive/2011/01/19/1938998.html

 

 

There is a small project to achieve functional character text box display in italics so the reference to xheditor, online search, 

<script src="jquery/jquery-1.4.2.min.js"></script>
<script>
  $(document).ready(function(){
//     var win = $('#ifr').contentWindow;
    var win =  document.getElementById('ifr').contentWindow.document;
      
    var html = "<html><body></body></html>"
    var s = $('#text_i').val();

   //针对IE and !IE 的情况
    win.designMode = "on";
    win.contentEditable = true;

   //

    win.open();
    //win.write(html);
    win.write(s);
    win.close();
     //alert(win);
  });
</script>
<span>

   <input type="text" id="text_i" value="<i>斜体</i>" style="display:none;"/>

   <iframe id="ifr" width="60" height="20" src="javascript:;">
      
   </iframe>
</span>

Reproduced in: https: //www.cnblogs.com/flex_fly/archive/2011/01/19/1938998.html

Guess you like

Origin blog.csdn.net/weixin_30335575/article/details/94787521