Htmledit.document.designmode= "on";
Htmledit is an IFrame object ID
Contenteditable= "True" can be set in IE
Set the div's Contenteditable property to True, you can see the effect in IE browser, the elements in the div become editable.
<div id= "tt" contenteditable= "true" ></div>
<body contenteditable= "true" ><!--the entire page can be edited-->.
Firefox can use JavaScript statements to set property Contentdocument.designmode to "on"
Iframename.document.designmode= "on";
Where Iframename is the name property of the IFRAME control.
Test passes in IE7 and FireFox2.0. If you want to initialize some content and style first, the code example is as follows:
Copy Code code as follows:
if (navigator.appname = "Microsoft Internet Explorer")
{
var Iframei d=frames["HtmlEditor"];
if (navigator.appVersion.indexOf ("MSIE 6.0", 0) ==-1) {iframeid.document.designmode= "on"}
IframeID.document.open ();
IframeID.document.write (Styleeditorheader);
IframeID.document.close ();
IframeID.document.body.contentEditable = "True";
Iframeid.document.body.innerhtml=hidenobjvalue;
iframeid.document.body.style.fontsize= "10pt";
}else
{
var _ff = navigator.userAgent.indexOf ("Firefox") >-1?true:false;
var iframeid=getobject ("HtmlEditor");
Htmleditor=iframeid.contentwindow;
htmleditor.document.designmode= "on"
HtmlEditor.document.open ();
HtmlEditor.document.write (Styleeditorheader);
HtmlEditor.document.close ();
HtmlEditor.document.body.contentEditable = "True";
Htmleditor.document.body.innerhtml=hidenobjvalue;
}