Skip to content

Commit

Permalink
doc: add oncut/oncuechange/oncopy/oncontextmenu/onclick document.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Jun 26, 2022
1 parent a6f9f68 commit 1c99657
Show file tree
Hide file tree
Showing 9 changed files with 377 additions and 43 deletions.
60 changes: 30 additions & 30 deletions .idoc/.filesStat.json
Original file line number Diff line number Diff line change
Expand Up @@ -3612,63 +3612,63 @@
"birthtime": "2022-05-29T10:18:16.994Z"
},
"docs/attribute/onblur.md": {
"atime": "2022-05-29T10:18:17.130Z",
"mtime": "2022-05-29T10:18:16.994Z",
"ctime": "2022-05-29T10:18:16.994Z",
"atime": "2022-06-26T13:21:00.627Z",
"mtime": "2022-06-26T13:21:00.595Z",
"ctime": "2022-06-26T13:21:00.595Z",
"birthtime": "2022-05-29T10:18:16.994Z"
},
"docs/attribute/oncanplay.md": {
"atime": "2022-05-29T10:18:17.135Z",
"mtime": "2022-05-29T10:18:16.995Z",
"ctime": "2022-05-29T10:18:16.995Z",
"atime": "2022-06-26T13:20:57.577Z",
"mtime": "2022-06-26T13:20:57.466Z",
"ctime": "2022-06-26T13:20:57.466Z",
"birthtime": "2022-05-29T10:18:16.994Z"
},
"docs/attribute/onbeforeunload.md": {
"atime": "2022-05-29T10:18:17.221Z",
"mtime": "2022-05-29T10:18:16.994Z",
"ctime": "2022-05-29T10:18:16.994Z",
"atime": "2022-06-26T13:21:03.622Z",
"mtime": "2022-06-26T13:21:03.600Z",
"ctime": "2022-06-26T13:21:03.600Z",
"birthtime": "2022-05-29T10:18:16.994Z"
},
"docs/attribute/oncanplaythrough.md": {
"atime": "2022-06-26T03:44:36.674Z",
"mtime": "2022-06-26T03:44:37.180Z",
"ctime": "2022-06-26T03:44:37.180Z",
"atime": "2022-06-26T13:20:52.624Z",
"mtime": "2022-06-26T13:20:52.552Z",
"ctime": "2022-06-26T13:20:52.552Z",
"birthtime": "2022-04-24T09:54:54.966Z"
},
"docs/attribute/onchange.md": {
"atime": "2022-06-26T04:01:09.500Z",
"mtime": "2022-06-26T04:01:09.714Z",
"ctime": "2022-06-26T04:01:09.714Z",
"atime": "2022-06-26T04:02:01.830Z",
"mtime": "2022-06-26T13:20:49.112Z",
"ctime": "2022-06-26T13:20:49.112Z",
"birthtime": "2022-04-24T09:54:54.966Z"
},
"docs/attribute/onclick.md": {
"atime": "2022-04-29T15:27:16.552Z",
"mtime": "2022-04-29T15:26:49.650Z",
"ctime": "2022-04-29T15:26:49.650Z",
"atime": "2022-06-26T13:20:45.543Z",
"mtime": "2022-06-26T13:20:45.512Z",
"ctime": "2022-06-26T13:20:45.512Z",
"birthtime": "2022-04-24T09:54:54.966Z"
},
"docs/attribute/oncontextmenu.md": {
"atime": "2022-04-29T15:27:16.242Z",
"mtime": "2022-04-29T15:26:49.513Z",
"ctime": "2022-04-29T15:26:49.513Z",
"atime": "2022-06-26T13:20:41.026Z",
"mtime": "2022-06-26T13:20:41.275Z",
"ctime": "2022-06-26T13:20:41.275Z",
"birthtime": "2022-04-24T09:54:54.966Z"
},
"docs/attribute/oncopy.md": {
"atime": "2022-04-29T15:27:16.421Z",
"mtime": "2022-04-29T15:26:49.621Z",
"ctime": "2022-04-29T15:26:49.621Z",
"atime": "2022-06-26T13:21:52.664Z",
"mtime": "2022-06-26T13:21:52.666Z",
"ctime": "2022-06-26T13:21:52.666Z",
"birthtime": "2022-04-24T09:54:54.966Z"
},
"docs/attribute/oncuechange.md": {
"atime": "2022-04-29T15:27:16.442Z",
"mtime": "2022-04-29T15:26:49.578Z",
"ctime": "2022-04-29T15:26:49.578Z",
"atime": "2022-06-26T13:20:32.215Z",
"mtime": "2022-06-26T13:20:32.149Z",
"ctime": "2022-06-26T13:20:32.149Z",
"birthtime": "2022-04-24T09:54:54.967Z"
},
"docs/attribute/oncut.md": {
"atime": "2022-04-29T15:27:17.377Z",
"mtime": "2022-04-29T15:26:50.376Z",
"ctime": "2022-04-29T15:26:50.376Z",
"atime": "2022-06-26T13:23:12.688Z",
"mtime": "2022-06-26T13:23:12.759Z",
"ctime": "2022-06-26T13:23:12.759Z",
"birthtime": "2022-04-24T09:57:42.250Z"
},
"docs/attribute/ondblclick.md": {
Expand Down
2 changes: 1 addition & 1 deletion docs/attribute/oncanplay.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ HTML oncanplay 属性

`oncanplay` 属性对每个元素都有以下浏览器支持:

| 元素 | ![chrome][1] | ![edge][2] | ![firefox][3] | ![safari][4] | ![opera][5] |
| 事件属性 | ![chrome][1] | ![edge][2] | ![firefox][3] | ![safari][4] | ![opera][5] |
| --- | --- | --- | --- | --- | --- |
| audio | Yes | 9.0 | Yes | Yes | Yes |
| embed | ❌ 不支持 | ❌ 不支持 | ❌ 不支持 | ❌ 不支持 | ❌ 不支持 |
Expand Down
2 changes: 1 addition & 1 deletion docs/attribute/oncanplaythrough.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ HTML oncanplaythrough 属性

`oncanplaythrough` 属性对每个元素都有以下浏览器支持:

| 元素 | ![chrome][1] | ![edge][2] | ![firefox][3] | ![safari][4] | ![opera][5] |
| 事件属性 | ![chrome][1] | ![edge][2] | ![firefox][3] | ![safari][4] | ![opera][5] |
| --- | --- | --- | --- | --- | --- |
| audio | Yes | 9.0 | Yes | Yes | Yes |
| video | Yes | 9.0 | Yes | Yes | Yes |
Expand Down
2 changes: 1 addition & 1 deletion docs/attribute/onchange.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function myFunction(val) {

## 浏览器支持

| 元素 | ![chrome][1] | ![edge][2] | ![firefox][3] | ![safari][4] | ![opera][5] |
| 事件属性 | ![chrome][1] | ![edge][2] | ![firefox][3] | ![safari][4] | ![opera][5] |
| --- | --- | --- | --- | --- | --- |
| onchange | Yes | Yes | Yes | Yes | Yes |
<!--rehype:style=width: 100%; display: inline-table;-->
Expand Down
69 changes: 67 additions & 2 deletions docs/attribute/onclick.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,69 @@
onclick.md
HTML onclick 属性
===

欢迎您编辑 <a target="__blank" href="https://github.com/jaywcjlove/html-tutorial/blob/main/docs/attribute/onclick.md">docs/attribute/onclick.md</a> 文件,共建 HTML Tutorial 文档。
## 定义和用法

`onclick` 属性在鼠标点击元素时触发。

## 适用于

`onclick` 属性是 [事件属性](../reference/attributes.md) 的一部分,可用于任何 HTML 元素。

| 元素 | 事件 |
| --- | --- |
| 所有 HTML 元素 | [onclick](../events/onclick.md) |
<!--rehype:style=width: 100%; display: inline-table;-->

## 示例

### Button 示例

单击按钮时执行 JavaScript:

```html
<button onclick="myFunction()">点击我</button>
```

```html idoc:preview:iframe
<button onclick="myFunction()">点击我</button>

<p id="demo"></p>

<p>单击按钮时会触发一个函数。 该函数在 id="demo" 的 p 元素中输出一些文本。</p>

<script>
function myFunction() {
document.getElementById("demo").innerHTML = "Hello World";
}
</script>
```

### P 示例

单击 \<p> 元素将其文本颜色更改为红色:

```html idoc:preview:iframe
<p id="demo" onclick="myFunction()">单击我以更改我的文本颜色。</p>

<script>
function myFunction() {
document.getElementById("demo").style.color = "red";
}
</script>
```

## 浏览器支持

| 事件属性 | ![chrome][1] | ![edge][2] | ![firefox][3] | ![safari][4] | ![opera][5] |
| --- | --- | --- | --- | --- | --- |
| onclick | Yes | Yes | Yes | Yes | Yes |
<!--rehype:style=width: 100%; display: inline-table;-->


[1]: ../assets/chrome.svg
[2]: ../assets/edge.svg
[3]: ../assets/firefox.svg
[4]: ../assets/safari.svg
[5]: ../assets/opera.svg


73 changes: 71 additions & 2 deletions docs/attribute/oncontextmenu.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,73 @@
oncontextmenu.md
HTML oncontextmenu 属性
===

欢迎您编辑 <a target="__blank" href="https://github.com/jaywcjlove/html-tutorial/blob/main/docs/attribute/oncontextmenu.md">docs/attribute/oncontextmenu.md</a> 文件,共建 HTML Tutorial 文档。
## 定义和用法

`oncontextmenu` 属性在用户右键单击元素以打开上下文菜单时触发。

**注意:** 虽然所有浏览器都支持 `oncontextmenu` 事件,但目前只有 Firefox 支持 `contextmenu` 属性。

## 适用于

`oncontextmenu` 属性是 [事件属性](../reference/attributes.md) 的一部分,可用于任何 HTML 元素。

| 元素 | 事件 |
| --- | --- |
| 所有 HTML 元素 | [oncontextmenu](../events/oncontextmenu.md) |

### 示例

触发上下文菜单时执行 JavaScript:


```html
<div oncontextmenu="myFunction()" contextmenu="mymenu">
```

```html idoc:preview:iframe
<style>
div {
background: yellow;
border: 1px solid black;
padding: 10px;
}
</style>
<div oncontextmenu="myFunction()" contextmenu="mymenu">
<p>在此框内右键单击以查看上下文菜单!</p>

<menu type="context" id="mymenu">
<menuitem label="Refresh" onclick="window.location.reload();" icon="ico_reload.png"></menuitem>
<menu label="Share on...">
<menuitem label="Twitter" icon="ico_twitter.png" onclick="window.open('//twitter.com/intent/tweet?text=' + window.location.href);"></menuitem>
<menuitem label="Facebook" icon="ico_facebook.png" onclick="window.open('//facebook.com/sharer/sharer.php?u=' + window.location.href);"></menuitem>
</menu>
<menuitem label="Email This Page" onclick="window.location='mailto:?body='+window.location.href;"></menuitem>
</menu>

</div>

<p><strong>注意:</strong> contextmenu <strong>属性</strong>仅适用于 Firefox! </p>

<script>
function myFunction() {
alert("You right-clicked inside the div!");
}
</script>
```

## 浏览器支持

| 事件属性 | ![chrome][1] | ![edge][2] | ![firefox][3] | ![safari][4] | ![opera][5] |
| --- | --- | --- | --- | --- | --- |
| oncontextmenu | Yes | Yes | Yes | Yes | Yes |
<!--rehype:style=width: 100%; display: inline-table;-->


[1]: ../assets/chrome.svg
[2]: ../assets/edge.svg
[3]: ../assets/firefox.svg
[4]: ../assets/safari.svg
[5]: ../assets/opera.svg



104 changes: 102 additions & 2 deletions docs/attribute/oncopy.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,104 @@
oncopy.md
HTML oncopy 属性
===

欢迎您编辑 <a target="__blank" href="https://github.com/jaywcjlove/html-tutorial/blob/main/docs/attribute/oncopy.md">docs/attribute/oncopy.md</a> 文件,共建 HTML Tutorial 文档。
## 定义和用法

`oncopy` 属性在用户复制元素内容时触发。

**提示:** 当用户复制使用 `<img>` 元素创建的元素(例如图像)时,也会触发 `oncopy` 属性。

**提示:** `oncopy` 属性主要用于具有 `type="text"``<input>` 元素。

**提示:** 复制元素/元素内容的三种方式:

* 按 <kbd>CTRL</kbd> + <kbd>C</kbd>
* 从浏览器的编辑菜单中选择“复制”
* 右键单击显示上下文菜单并选择“复制”命令

## 适用于

`oncopy` 属性是 [事件属性](../reference/attributes.md) 的一部分,可用于任何 HTML 元素。

| 元素 | 事件 |
| --- | --- |
| 所有 HTML 元素 | [oncopy](../events/oncopy.md) |
<!--rehype:style=width: 100%; display: inline-table;-->

## 示例

### Input 示例

在复制 \<input> 元素的某些文本时执行 JavaScript:

```html
<input type="text" oncopy="myFunction()" value="尝试复制此文本">
```

```html idoc:preview:iframe
<input type="text" oncopy="myFunction()" value="尝试复制此文本">

<p id="demo"></p>

<script>
function myFunction() {
document.getElementById("demo").innerHTML = "你复制了文字!"
}
</script>
```

### P 示例

在复制 \<p> 元素的某些文本时执行 JavaScript:

```html
<p oncopy="myFunction()">尝试复制此文本</p>
```

```html idoc:preview:iframe
<p oncopy="myFunction()">尝试复制此文本</p>

<script>
function myFunction() {
alert("你复制了文字!");
}
</script>
```

### Img 示例

复制图像时执行 JavaScript:

```html
<img src="xxx.gif" oncopy="myFunction()">
```

```html idoc:preview:iframe
<p>尝试复制下面的图像(右键单击图像并选择“复制图像”)。</p>

<img src="../assets/editors-001.png" oncopy="myFunction()" alt="editors image" height="150">

<p><strong>笔记:</strong> 此示例在某些浏览器中可能无法按预期工作。</p>

<script>
function myFunction() {
alert("你复制了图片!");
}
</script>
```

## 浏览器支持

| 事件属性 | ![chrome][1] | ![edge][2] | ![firefox][3] | ![safari][4] | ![opera][5] |
| --- | --- | --- | --- | --- | --- |
| oncopy | Yes | Yes | Yes | Yes | Yes |
<!--rehype:style=width: 100%; display: inline-table;-->

**注意:** 在尝试复制图像时,oncopy 属性在某些浏览器中可能无法正常工作(参见上面的示例)。

[1]: ../assets/chrome.svg
[2]: ../assets/edge.svg
[3]: ../assets/firefox.svg
[4]: ../assets/safari.svg
[5]: ../assets/opera.svg


Loading

0 comments on commit 1c99657

Please sign in to comment.