Introduction to the properties of DesignMode and Contenteditable in the Editor _ Web page Editor

Source: Internet
Author: User
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;
}

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.