javascript - Textarea copy with formatting -
I want a text in my page to get a copy with formatting when copying from my web pages. When I use TinyMCE or CkEditor, it is showing near the toolbar. I do not want to show a text editor toolbar near Textera, it should look like Texteria, but with formatting during paste. Suggest me some tips.
You can use div with
contenteditable = "True" . In the following example you will find a
div first and a
textarea next, from a
button . If you paste something in
div and click on the
button , you will see the HTML of the content pasted within
textarea . Of course, you can hide this
textarea with CSS (
display: none: ) and then use it as a part of an HTML form. The general practice is to submit the form to copy the contents of
div in the form of
textarea ???? Also, the function applied to the click of the
button also is
document.myForm.submit (); .
can contain a line such as & lt. ; Html & gt; & Lt; Top & gt; & Lt; Style type = "text / css" & gt; #myDiv, #myTxt {width: 300px; Height: 180px; Limit: 1px solid black; } #myDiv {Overflow: Auto; } #IBTN {Display: Block; Margin: 6px 0px; } & Lt; / Style & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Div id = "myDiv" contenteditable = "true" & gt; & Lt; / Div & gt; & Lt; Button type = "button" id = "myBtn" & gt; See HTML below & lt; / Button & gt; & Lt; Textarea id = "myTxt" read-only & gt; & Lt; / Textarea & gt; & Lt; Script type = "text / javascript" & gt; Document.getElementById ("myBtn"). Onclick = function () {document.getElementById ("myTxt"). InnerHTML = document.getElementById ("myDiv"). InnerHTML; } & Lt; / Script & gt; & Lt; / Body & gt; & Lt; / Html & gt;
Comments
Post a Comment