Hello all,
Working with rich text editor a user can copy and paste the data any where in rick text editor and we wanted to remove the html format of that copied data so that only plain text can be copied.
To do that we have to get the copied data to clipboard using javascript which can manipulate and that paste it later on.
To do that we have following code packet :
in HTML we have :
<input type="text" oncopy="getData(this,event)" value="Try to copy this text">
in JavaScript we have:
function getData(x, e) {
var copiedHtml = e.clipboardData.getData("text/html"); // This will give the copied html
var copyText = e.clipboardData.getData("text/plain"); // This will give the copied text
return copyText ;
}
0 Comment(s)