Make an IFRAME editable

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.