blob: 9f04db7952df893fe3c0bf97f2ddbf9ac21c1c7c (
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
---
title: Document.designMode
slug: Web/API/Document/designMode
tags:
- API
- Document
- HTML DOM
- NeedsBrowserCompatibility
- Property
translation_of: Web/API/Document/designMode
---
<div>{{ ApiRef() }}</div>
<div> </div>
<h2 id="Summary" name="Summary">概要</h2>
<p><code>document.designMode</code> 控制整個文件是否能夠編輯。可用的數值是 <code>"on"</code> 和 <code>"off"</code>。根據規範,這個屬性預設值為 <code>"off"</code>。Firefox 遵從這個標準。較早以前的 Chrome 和 IE 預設值是 <code>"inherit"</code>。從 Chrome 43 起,預設值是 「<code>off</code>」;不再支援「<code>inherit</code>」。在 IE6-10 中,數值為大寫英文字母。</p>
<h2 id="語法">語法</h2>
<pre class="brush: js">var mode = document.designMode;
document.designMode = "on";
document.designMode = "off";</pre>
<h2 id="Example" name="Example">範例</h2>
<p>讓 {{HTMLElement("iframe")}} 的文件可以給使用者編輯:</p>
<pre>iframeNode.contentDocument.designMode = "on";
</pre>
<h2 id="規範">規範</h2>
<table class="standard-table">
<tbody>
<tr>
<th scope="col">規範</th>
<th scope="col">狀態</th>
<th scope="col">註解</th>
</tr>
<tr>
<td>{{SpecName('HTML WHATWG', '#making-entire-documents-editable:-the-designmode-idl-attribute', 'designMode')}}</td>
<td>{{Spec2('HTML WHATWG')}}</td>
<td>Initial definition.</td>
</tr>
</tbody>
</table>
<h2 id="瀏覽器相容性" style="font-size: 2.14285714285714rem;">瀏覽器相容性</h2>
<p>{{ CompatibilityTable() }}</p>
<div id="compat-desktop">
<table class="compat-table">
<tbody>
<tr>
<th style="line-height: 16px;">功能</th>
<th style="line-height: 16px;">Chrome</th>
<th style="line-height: 16px;">Edge</th>
<th style="line-height: 16px;">Firefox (Gecko)</th>
<th style="line-height: 16px;">Internet Explorer</th>
<th style="line-height: 16px;">Opera</th>
<th style="line-height: 16px;">Safari</th>
</tr>
<tr>
<td>基本支援</td>
<td>{{ CompatVersionUnknown() }}</td>
<td>{{ CompatVersionUnknown() }}</td>
<td>{{ CompatVersionUnknown() }}</td>
<td>{{ CompatVersionUnknown() }}</td>
<td>{{ CompatVersionUnknown() }}</td>
<td>{{ CompatVersionUnknown() }}</td>
</tr>
</tbody>
</table>
</div>
<div id="compat-mobile">
<table class="compat-table">
<tbody>
<tr>
<th style="line-height: 16px;">功能</th>
<th style="line-height: 16px;">Android</th>
<th style="line-height: 16px;">Android Webview</th>
<th style="line-height: 16px;">Edge</th>
<th style="line-height: 16px;">Firefox Mobile (Gecko)</th>
<th style="line-height: 16px;">IE Mobile</th>
<th style="line-height: 16px;">Opera Mobile</th>
<th style="line-height: 16px;">Safari Mobile</th>
<th style="line-height: 16px;">Chrome for Android</th>
</tr>
<tr>
<td>基本支援</td>
<td>{{CompatNo}}</td>
<td>{{ CompatVersionUnknown() }}</td>
<td>{{ CompatUnknown() }}</td>
<td>{{ CompatUnknown() }}</td>
<td>{{ CompatUnknown() }}</td>
<td>{{ CompatUnknown() }}</td>
<td>{{ CompatUnknown() }}</td>
<td>{{ CompatVersionUnknown() }}</td>
</tr>
</tbody>
</table>
</div>
<h2 id="See_also" name="See_also">參考</h2>
<ul>
<li><a href="/zh-TW/docs/Rich-Text_Editing_in_Mozilla">Rich-Text Editing in Mozilla</a></li>
<li>{{domxref("HTMLElement.contentEditable")}}</li>
<li><a href="https://msdn.microsoft.com/en-us/library/ms533720(v=vs.85).aspx">designMode property</a> on MSDN</li>
</ul>
|