CopyCode The Code is as follows: function keypress (EV ){
If (EV. keycode = 13 ){
// Create an area where the cursor is located.
VaR range = Document. selection. createRange ();
// Set the content of the region to a line break.
Range. Text = "\ n ";
// Move the start point of the region to the right to show the length of one character.
Range. movestart ("character", 1 );
// Move the cursor to the end of the area. (If false, the cursor is moved to the starting position ).
Range. Collapse (true );
// Because of the above operations, the position of the area is after \ n, so when you select again, the cursor ends at the end of the new line. Complete the line feed.
Range. Select ();
// Invalidate the event
Return false;
}
Return true;
}
// Initialize the Editable IFRAME
Content.doc ument. designMode = "on ";
Content.doc ument. onkeypress = function () {return keypress (content. Event );};Copy codeThe Code is 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>
Obtain the code in the On-behalf editing boxCopy codeThe Code is as follows: window. Frames ["content" .doc ument. Body. innerhtml