清除剪贴板以禁止未经授权的复制,插入消息? [英] Clear clipboard to prohibit unauthorised copying, insert message?

查看:102
本文介绍了清除剪贴板以禁止未经授权的复制,插入消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用ctrl + c复制网站数据时,是否可以将自己的消息写入剪贴板?我找到了一些清除剪贴板的Javascript - 知道是否还有一些可以写入它的东西很有趣,例如用请使用我们网站的印刷版替换剪贴板中的文本。

Is it possible to write your own message into the clipboard when copying website data using ctrl+c? I've found some Javascript that clears the clipboard - would be interesting to know if there's something that would write to it as well, i.e. replace the text in the clipboard with something like 'Please use the print edition of our website'.

  function clearData() {
    window.clipboardData.setData('text', '')
  }

  function cldata() {
    if (clipboardData) {
      clipboardData.clearData();
    }
  }
  setInterval("cldata()", 1000);

<body ondragstart="return false;" onselectstart="return false;" oncontextmenu="return false;" onload="clearData();" onblur="clearData();">

  <h1>Example text</h1>
<input type="text">

推荐答案

您无法纯粹通过JavaScript来完成。

You can't do it purely through JavaScript.

剪贴板的JavaScript编辑被认为是安全漏洞(并且存在

JavaScript editing of the clipboard is considered a security vulnerability (and there is much more discussion on this).

您可以通过使用Flash进行剪贴板访问的黑客来进行交互JavaScript。

You could do it through hacks that uses Flash for clipboard access interacting with JavaScript.

这篇关于清除剪贴板以禁止未经授权的复制,插入消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆