Question about editing and dragging images on a javascript webpage

Source: Internet
Author: User

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

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.