blob: 12ff84d885fe1514298931e1dc07450fae56c777 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
---
title: element.oncopy
slug: Web/API/HTMLElement/oncopy
translation_of: Web/API/HTMLElement/oncopy
---
<p>{{ Fx_minversion_header("3") }} {{ ApiRef() }}</p>
<h3 id="Summary" name="Summary">概述</h3>
<p><strong>oncopy</strong>属性用来获取或设置当前元素的<code>copy</code>事件的事件处理函数.</p>
<h3 id="Syntax" name="Syntax">语法</h3>
<pre class="eval"><em>element</em>.oncopy = <em>functionRef</em>;
</pre>
<p><em>functionRef</em> 是一个函数名或者函数表达式.</p>
<h3 id="Example" name="Example">例子</h3>
<pre><html>
<head>
<title>oncopy示例演示</title>
<script>
function log(txt)
{
document.getElementById("log").appendChild(document.createTextNode(txt + "\n"));
}
</script>
</head>
<body>
<div oncopy="log('复制被阻止!'); return false;">试着复制这句话!</div>
<h3>Log</h3>
<textarea rows="15" cols="80" id="log" readonly="true"></textarea>
</body>
</html>
</pre>
<p>上例演示了如何禁止复制浏览器中的一段话.</p>
<h3 id="Notes" name="Notes">备注</h3>
<p>当用户尝试复制选中元素或文本时会触发<code>copy</code>事件.</p>
<h3 id="Specification" name="Specification">规范</h3>
<p>不属于任何公开的规范.</p>
<h3 id="See_also" name="See_also">相关链接</h3>
<ul>
<li><code><a href="/zh-cn/DOM/element.oncut" title="zh-cn/DOM/element.oncut">oncut</a></code></li>
<li><code><a href="/zh-cn/DOM/element.onpaste" title="zh-cn/DOM/element.onpaste">onpaste</a></code></li>
</ul>
<p>{{ languages( { "ja": "ja/DOM/element.oncopy", "en": "en/DOM/element.oncopy" } ) }}</p>
|