Copy Code code as follows:
function keyPress (EV) {
if (ev.keycode==13) {
Creates an area at the cursor location.
var range=document.selection.createrange ();
Sets the content of the range to a newline character.
Range.text= "\ n";
Moves the start point of the range to the right by the length of one character.
Range.movestart ("character", 1);
Moves the cursor to the end of the range. (If False, move to start position).
Range.collapse (TRUE);
Because of the series of actions above, the location of the area is in the \ n, so when you select again, the cursor is at the end of the new line. Finish wrapping.
Range.Select ();
Make an event invalid
return false;
}
return true;
}
Initializing an editable IFRAME
Content.document.designmode= "on";
Content.document.onkeypress=function () {return keyPress (content.event);};
Copy Code code as follows:
<div id= "Iframewrapper" >
<iframe id= "Content" name= "content" style= "width:400;height:400;font-size:12px;border:solid 1px #ccc;" Frameborder=0></iframe>
</div>
The code that replaces the content in the edit box
Copy Code code as follows:
window.frames["Content"].document.body.innerhtml