JavaScript page edit box and drag-and-drop Picture Problem _ page Editor

Source: Internet
Author: User
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
Related Article

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.