text editor

The so-called text editor:

1. Make the iframe editable via js

<iframe id="inputArea" contenteditable="true"  style="border:solid 1px;width: 100%;height: 100px;background-color: #fff" ></iframe>

function

init() {

ifr = document.getElementById("inputArea");

doc = ifr.contentDocument || ifr.contentWindow.document; // W3C || IE

doc.designMode="on";

//doc.contentEditable=true; This does not seem to be suitable for other tags such as iframe and P div

       alert($("#divInput").html());

alert(doc.body.innerHTML);

}

 

2. Add contenteditable="true" to tags such as div p 

<div contenteditable="true"  id="divInput" style="width: 100px;height: 100px"></div>

 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326562509&siteId=291194637