functionEnableedit () {varEditor; Editor= document.getElementById ("Htmledit"). Contentwindow; //for IE browser, make it editableEditor.document.designMode = ' on '; Editor.document.contentEditable=true; //for compatible with FireFox, it should open and write somethingEditor.document.open (); Editor.document.writeln (' ); Editor.document.writeln (' <style>body {background:white;font-size:9pt;margin:2px; padding:0px;} </style> '); Editor.document.writeln (' ); Editor.document.close ();}<iframe id= "Htmledit" marginheight= "1" marginwidth= "1" width= "100%" height= "312" ></iframe>
<iframe src= "" Name= "editor" id= "editor" style= "border:1px solid RGB (204, 204, 204);" frameborder= "0" height= "$" wid Th= "></iframe><div><input" type= "button" onclick= "Insert (1)" value= "Insert Image" >< Input type= "button" onclick= "Insert (2)" value= "Insert Text" ></div><script>_win=$ (' #editor ') [0]. Contentwindow; We use the _win variable instead of the iframe window _doc=_win.document; Document _doc.designmode = ' on ' with _doc variable instead of IFRAME, if ($.browser.msie) {_doc.write (' '); _doc.close ();} function inserthtml (sHtml) {_win.focus (); if ($.browser.msie) {_doc.selection.createrange (). pastehtml (sHtml); }else{_doc.execcommand (' inserthtml ', ', sHtml); }}function Insert (type) {if (type==1) {inserthtml (' ');} else{inserthtml (' haha ');}} </script>
Make an IFRAME editable