有什么方法可以防止某人使用JavaScript从CKEDITOR复制文本?

时间:2018-08-20 15:23:33

标签: javascript ckeditor ckeditor4.x

为防止粘贴到下面的CKEditor对我有用。

window.CKEDITOR.instances.PEGACKEDITOR0.on('paste', function(evt){evt.cancel();}) 

类似地,有什么方法可以防止某人使用JavaScript从CKEditor复制文本?

1 个答案:

答案 0 :(得分:0)

对于所有文档,您都可以尝试以下操作:

<script type="text/javascript"> window.onload = preventing;


   function preventing () { 
 /* Disable right click on web page  */
     document.onclick("contextmenu",function(e){
     return false; }); 

/* Disable cut, copy and paste on web page */ 

document.bind('cut copy paste', function (e) {
          e.preventDefault(); }); };

</script>

Adapted from this source

如果只需要在ckedit区域上:

var element = CKEDITOR.document.getById( 'myElement' );
element.on( 'click', function( ev )
{
    // The DOM event object is passed by the "data" property.
    var domEvent = ev.data;
    // Prevent the click to chave any effect in the element.
    domEvent.stopPropagation();
})

Source