Skip to content

Commit

Permalink
doc: add onbeforeprint/onbeforeunload/onblur/oncanplay document.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed May 29, 2022
1 parent 0da66fe commit f7306c2
Show file tree
Hide file tree
Showing 7 changed files with 290 additions and 60 deletions.
90 changes: 45 additions & 45 deletions .idoc/.filesStat.json
Original file line number Diff line number Diff line change
Expand Up @@ -2250,9 +2250,9 @@
"birthtime": "2022-04-24T07:43:17.339Z"
},
"docs/tags/menu.md": {
"atime": "2022-05-14T17:50:40.465Z",
"mtime": "2022-05-14T17:50:40.466Z",
"ctime": "2022-05-14T17:50:40.466Z",
"atime": "2022-05-16T01:48:44.021Z",
"mtime": "2022-05-16T01:48:41.947Z",
"ctime": "2022-05-16T01:48:41.947Z",
"birthtime": "2022-04-30T10:33:33.935Z"
},
"docs/tags/menu_type.md": {
Expand Down Expand Up @@ -2400,9 +2400,9 @@
"birthtime": "2022-04-24T07:43:17.340Z"
},
"docs/tags/noframes.md": {
"atime": "2022-05-01T07:33:35.136Z",
"mtime": "2022-05-01T07:33:32.797Z",
"ctime": "2022-05-01T07:33:32.797Z",
"atime": "2022-05-16T01:48:44.366Z",
"mtime": "2022-05-16T01:48:41.985Z",
"ctime": "2022-05-16T01:48:41.985Z",
"birthtime": "2022-04-24T07:43:17.340Z"
},
"docs/tags/noscript.md": {
Expand Down Expand Up @@ -2754,9 +2754,9 @@
"birthtime": "2022-04-25T13:38:12.550Z"
},
"docs/tags/small.md": {
"atime": "2022-05-03T17:19:39.025Z",
"mtime": "2022-05-03T17:19:37.935Z",
"ctime": "2022-05-03T17:19:37.935Z",
"atime": "2022-05-16T01:48:43.984Z",
"mtime": "2022-05-16T01:48:41.947Z",
"ctime": "2022-05-16T01:48:41.947Z",
"birthtime": "2022-04-24T07:43:17.342Z"
},
"docs/tags/source.md": {
Expand Down Expand Up @@ -2820,9 +2820,9 @@
"birthtime": "2022-04-25T13:38:12.550Z"
},
"docs/tags/sub.md": {
"atime": "2022-05-01T10:00:33.728Z",
"mtime": "2022-05-01T09:51:28.102Z",
"ctime": "2022-05-01T09:51:28.102Z",
"atime": "2022-05-16T01:48:44.344Z",
"mtime": "2022-05-16T01:48:41.985Z",
"ctime": "2022-05-16T01:48:41.985Z",
"birthtime": "2022-04-24T07:43:17.342Z"
},
"docs/tags/style_type.md": {
Expand All @@ -2838,9 +2838,9 @@
"birthtime": "2022-04-24T07:43:17.342Z"
},
"docs/tags/svg.md": {
"atime": "2022-05-01T10:00:50.730Z",
"mtime": "2022-05-01T10:00:37.207Z",
"ctime": "2022-05-01T10:00:37.207Z",
"atime": "2022-05-16T01:48:43.993Z",
"mtime": "2022-05-16T01:48:41.897Z",
"ctime": "2022-05-16T01:48:41.897Z",
"birthtime": "2022-04-24T07:43:17.342Z"
},
"docs/tags/sup.md": {
Expand Down Expand Up @@ -2880,9 +2880,9 @@
"birthtime": "2022-04-25T13:38:12.550Z"
},
"docs/tags/template.md": {
"atime": "2022-05-14T17:52:54.607Z",
"mtime": "2022-05-14T17:52:54.571Z",
"ctime": "2022-05-14T17:52:54.571Z",
"atime": "2022-05-16T01:48:43.989Z",
"mtime": "2022-05-16T01:48:41.947Z",
"ctime": "2022-05-16T01:48:41.947Z",
"birthtime": "2022-04-24T07:43:17.343Z"
},
"docs/tags/textarea_autofocus.md": {
Expand Down Expand Up @@ -3042,9 +3042,9 @@
"birthtime": "2022-04-24T07:43:17.343Z"
},
"docs/tags/tr.md": {
"atime": "2022-05-01T11:55:05.778Z",
"mtime": "2022-05-01T11:53:53.960Z",
"ctime": "2022-05-01T11:53:53.960Z",
"atime": "2022-05-16T01:48:43.990Z",
"mtime": "2022-05-16T01:48:41.984Z",
"ctime": "2022-05-16T01:48:41.984Z",
"birthtime": "2022-04-24T07:43:17.343Z"
},
"docs/tags/track_label.md": {
Expand Down Expand Up @@ -3090,15 +3090,15 @@
"birthtime": "2022-04-24T07:43:17.343Z"
},
"docs/tags/var.md": {
"atime": "2022-05-03T17:19:39.030Z",
"mtime": "2022-05-03T17:19:37.935Z",
"ctime": "2022-05-03T17:19:37.935Z",
"atime": "2022-05-16T01:48:43.981Z",
"mtime": "2022-05-16T01:48:41.918Z",
"ctime": "2022-05-16T01:48:41.918Z",
"birthtime": "2022-04-24T07:43:17.343Z"
},
"docs/tags/video.md": {
"atime": "2022-05-03T16:22:16.449Z",
"mtime": "2022-05-16T01:48:41.174Z",
"ctime": "2022-05-16T01:48:41.174Z",
"atime": "2022-05-29T10:14:59.107Z",
"mtime": "2022-05-29T10:14:59.731Z",
"ctime": "2022-05-29T10:14:59.731Z",
"birthtime": "2022-04-24T07:43:17.343Z"
},
"docs/tags/video_autoplay.md": {
Expand Down Expand Up @@ -3162,9 +3162,9 @@
"birthtime": "2022-04-25T13:38:12.552Z"
},
"docs/tags/wbr.md": {
"atime": "2022-05-01T13:13:01.341Z",
"mtime": "2022-05-01T13:12:55.011Z",
"ctime": "2022-05-01T13:12:55.011Z",
"atime": "2022-05-16T01:48:44.271Z",
"mtime": "2022-05-16T01:48:41.985Z",
"ctime": "2022-05-16T01:48:41.985Z",
"birthtime": "2022-04-24T07:43:17.343Z"
},
"docs/attribute/global/class.md": {
Expand Down Expand Up @@ -3222,9 +3222,9 @@
"birthtime": "2022-04-24T07:17:32.209Z"
},
"docs/attribute/global/spellcheck.md": {
"atime": "2022-05-09T04:16:14.824Z",
"mtime": "2022-05-09T04:16:14.446Z",
"ctime": "2022-05-09T04:16:14.446Z",
"atime": "2022-05-16T10:46:52.068Z",
"mtime": "2022-05-16T10:48:44.160Z",
"ctime": "2022-05-16T10:48:44.160Z",
"birthtime": "2022-04-24T07:17:32.209Z"
},
"docs/attribute/global/style.md": {
Expand Down Expand Up @@ -3606,27 +3606,27 @@
"birthtime": "2022-04-24T09:54:54.966Z"
},
"docs/attribute/onbeforeprint.md": {
"atime": "2022-04-29T15:27:16.629Z",
"mtime": "2022-04-29T15:26:49.651Z",
"ctime": "2022-04-29T15:26:49.651Z",
"atime": "2022-05-29T09:56:41.190Z",
"mtime": "2022-05-29T09:56:41.157Z",
"ctime": "2022-05-29T09:56:41.157Z",
"birthtime": "2022-04-24T09:54:54.966Z"
},
"docs/attribute/onblur.md": {
"atime": "2022-04-29T15:27:17.106Z",
"mtime": "2022-04-29T15:26:49.653Z",
"ctime": "2022-04-29T15:26:49.653Z",
"atime": "2022-05-29T10:01:47.864Z",
"mtime": "2022-05-29T10:01:48.298Z",
"ctime": "2022-05-29T10:01:48.298Z",
"birthtime": "2022-04-24T09:54:54.966Z"
},
"docs/attribute/oncanplay.md": {
"atime": "2022-04-29T15:27:16.608Z",
"mtime": "2022-04-29T15:26:49.651Z",
"ctime": "2022-04-29T15:26:49.651Z",
"atime": "2022-05-29T10:15:13.153Z",
"mtime": "2022-05-29T10:15:27.829Z",
"ctime": "2022-05-29T10:15:27.829Z",
"birthtime": "2022-04-24T09:54:54.966Z"
},
"docs/attribute/onbeforeunload.md": {
"atime": "2022-04-29T15:27:17.309Z",
"mtime": "2022-04-29T15:26:49.794Z",
"ctime": "2022-04-29T15:26:49.794Z",
"atime": "2022-05-29T09:53:37.755Z",
"mtime": "2022-05-29T09:53:37.692Z",
"ctime": "2022-05-29T09:53:37.692Z",
"birthtime": "2022-04-24T09:54:54.966Z"
},
"docs/attribute/oncanplaythrough.md": {
Expand Down
4 changes: 3 additions & 1 deletion docs/attribute/global/spellcheck.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ HTML `spellcheck` 属性
带有拼写检查的可编辑段落:

```html idoc:preview
<p contenteditable="true" spellcheck="true">这是一个段落。</p>
<p contenteditable="true" spellcheck="true">这是一个段落,不检查英文单词拼写。</p>
<input spellcheck="false" placeholder="不检查英文单词拼写">
<input spellcheck="true" placeholder="检查英文单词拼写">
```

## 定义和使用
Expand Down
52 changes: 50 additions & 2 deletions docs/attribute/onbeforeprint.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,52 @@
onbeforeprint.md
HTML onbeforeprint 属性
===

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

`onbeforeprint` 属性在页面即将被打印时触发(在打印对话框出现之前)。

**提示:** `onbeforeprint` 属性通常与 `onafterprint` 属性一起使用。

## 适用于

`onbeforeprint` 属性是 [事件属性](../reference/eventattributes.md) 的一部分,可用于以下元素:

| 元素 | 事件 |
| --- | --- |
| [\<body>](../tags/body.md) | [onbeforeprint](../attribute/onbeforeprint.md) |
<!--rehype:style=width: 100%; display: inline-table;-->

## 示例

在即将打印页面时执行 JavaScript:

```html idoc:preview:iframe
<body onbeforeprint="myFunction()">

<h1>尝试打印此文档</h1>
<p><b>提示:</b> 键盘快捷键,例如 Ctrl+P/Command+P 设置要打印的页面。</p>
<p><b>注意:</b> Safari 和 Opera 不支持 onbeforeprint 事件。</p>

<script>
function myFunction() {
alert("You are about to print this document!");
}
</script>
</body>
```

## 浏览器支持

表中的数字指定了完全支持该事件的第一个浏览器版本。

| 事件属性 | ![chrome][1] | ![edge][2] | ![firefox][3] | ![safari][4] | ![opera][5] |
| --- | --- | --- | --- | --- | --- |
| onbeforeprint | 63 | 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
66 changes: 64 additions & 2 deletions docs/attribute/onbeforeunload.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,66 @@
onbeforeunload.md
HTML onbeforeunload 属性
===

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

`onbeforeunload` 事件在文档即将被卸载时触发。

此事件允许您在确认对话框中显示一条消息,以通知用户他/她是要留下还是离开当前页面。

确认框中显示的默认消息在不同的浏览器中有所不同。 但是,标准消息类似于“您确定要离开此页面吗?”。 您无法删除此消息。

但是,您可以将自定义消息与默认消息一起编写。 请参阅此页面上的第一个示例。

**注意:** 在 Firefox 中,只会显示默认消息(不是自定义消息(如果有))。

## 适用于

`onbeforeunload` 属性是 [Event Attributes](../attribute/onbeforeunload.md) 的一部分,可用于以下元素:

| 元素 | 事件 |
| --- | --- |
| [\<body>](../tags/body.md) | [onbeforeunload](../attribute/onbeforeunload.md) |
<!--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


## 示例

当页面即将被卸载时执行 JavaScript:

```html idoc:preview:iframe
<body onbeforeunload="return myFunction()">
<p>关闭此窗口,按 F5 或单击下面的链接以调用 onbeforeunload 事件。</p>

<a href="https://jaywcjlove.github.io/html-tutorial">单击此处访问 https://jaywcjlove.github.io/html-tutorial</a>

<script>
function myFunction() {
return "在这里写一些聪明的东西......";
}
</script>
</body>
```

## 浏览器支持

表中的数字指定了完全支持该事件的第一个浏览器版本。

| 事件属性 | ![chrome][1] | ![edge][2] | ![firefox][3] | ![safari][4] | ![opera][5] |
| --- | --- | --- | --- | --- | --- |
| onbeforeunload | Yes | Yes | Yes | Yes | 15.0 |
<!--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

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

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

`onblur` 属性会在元素失去焦点时触发。

Onblur 最常与表单验证代码一起使用(例如,当用户离开表单字段时)。

**提示:** `onblur` 属性与 `onfocus` 属性相反。

## 适用于

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

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

## 示例

当用户离开时验证输入字段:

```html idoc:preview:iframe
输入你的名字: <input type="text" name="fname" id="fname" onblur="myFunction()">
<p>当您离开输入字段时,会触发一个函数,将输入文本转换为大写。</p>

<script>
function myFunction() {
var x = document.getElementById("fname");
x.value = x.value.toUpperCase();
}
</script>
```

## 浏览器支持

| 事件属性 | ![chrome][1] | ![edge][2] | ![firefox][3] | ![safari][4] | ![opera][5] |
| --- | --- | --- | --- | --- | --- |
| onblur | 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

Loading

0 comments on commit f7306c2

Please sign in to comment.