From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/zh-cn/web/api/htmlelement/oncut/index.html | 46 ++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 files/zh-cn/web/api/htmlelement/oncut/index.html (limited to 'files/zh-cn/web/api/htmlelement/oncut/index.html') diff --git a/files/zh-cn/web/api/htmlelement/oncut/index.html b/files/zh-cn/web/api/htmlelement/oncut/index.html new file mode 100644 index 0000000000..e8d5c9c7ee --- /dev/null +++ b/files/zh-cn/web/api/htmlelement/oncut/index.html @@ -0,0 +1,46 @@ +--- +title: element.oncut +slug: Web/API/HTMLElement/oncut +translation_of: Web/API/HTMLElement/oncut +--- +

{{ Fx_minversion_header("3") }} {{ ApiRef() }}

+

概述

+

oncut属性用来获取或设置当前元素的cut事件的事件处理函数.

+

语法

+
element.oncut = functionRef;
+
+

functionRef 是一个函数名或者函数表达式.

+

例子

+
<html>
+<head>
+<title>oncut示例演示</title>
+
+<script>
+  function log(txt)
+  {
+    document.getElementById("log").appendChild(document.createTextNode(txt + "\n"));
+  }
+</script>
+</head>
+
+<body>
+<h3>按说明进行操作!</h3>
+<textarea rows="3" cols="80" oncopy="log('复制成功!');" oncut="log('剪切被阻止!'); return false;">
+  尝试剪切和复制该文本域内的文本!
+</textarea>
+<h3>Log</h3>
+<textarea rows="15" cols="80" id="log" readonly="true"></textarea>
+</body>
+</html>
+
+

上例演示了如何允许复制一个文本域内的文本,但禁止剪切那些文本.并把每次操作结果打印出来.

+

备注

+

当用户尝试剪切选中元素或文本时会触发cut事件.

+

规范

+

不属于任何公开的规范.

+

相关链接

+ +

{{ languages( { "ja": "ja/DOM/element.oncut" ,"en": "en/DOM/element.oncut" } ) }}

-- cgit v1.2.3-54-g00ecf