简体   繁体   中英

Disable Copy-Paste from the Text Editor

 @if (Model.CanMaintainNcrLineManagement) { <tr> <td>@Html.TextAreaFor(model => model.Description, new { id = "txArNcrLineDescriptionValue", @style = "height:520px" })</td> </tr> } else { <tr class="read-only-editor"> <td>@Html.TextAreaFor(model => model.Description, new { id = "txArNcrLineDescriptionReadOnly", @style = "height:520px" })</td> </tr> } 

I want to disable the copy-past option from the text editor box. I have used below both codes to disable it but its not working. Please give me some solution

 $('body').bind('copy paste', function(e) { e.preventDefault(); return false; }); 
 <body oncopy="return false" oncut="return false" onpaste="return false"> 

Change your code and your text editor must be inside body tag and will prevent all inside body tag.

<body oncopy="return false" oncut="return false" onpaste="return false">

To

<body onselectstart="return false" onpaste="return false;" onCopy="return false" onCut="return false" onDrag="return false" onDrop="return false"> 

I tested this in Chrome 66.0.3359.181, IE 11, and FireFox 59.0.3 and it is disabling copying and pasting into anything in the body or the input.

  $('body').bind('copy paste', function (e) { e.preventDefault(); return false; }); 
 <body oncopy="return false" oncut="return false" onpaste="return false"> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM