diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/windoweventhandlers/onlanguagechange | |
parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
download | translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2 translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip |
initial commit
Diffstat (limited to 'files/zh-cn/web/api/windoweventhandlers/onlanguagechange')
-rw-r--r-- | files/zh-cn/web/api/windoweventhandlers/onlanguagechange/index.html | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/windoweventhandlers/onlanguagechange/index.html b/files/zh-cn/web/api/windoweventhandlers/onlanguagechange/index.html new file mode 100644 index 0000000000..ccabcc1c2e --- /dev/null +++ b/files/zh-cn/web/api/windoweventhandlers/onlanguagechange/index.html @@ -0,0 +1,101 @@ +--- +title: WindowEventHandlers.onlanguagechange +slug: Web/API/WindowEventHandlers/onlanguagechange +translation_of: Web/API/WindowEventHandlers/onlanguagechange +--- +<p>{{APIRef("HTML DOM")}}{{SeeCompatTable}}</p> + +<p><code><strong>WindowEventHandlers.onlanguagechange</strong></code> 事件是一个属性,包含待执行的代码。当 {{domxref("Event")}} 类型的 {{event("languagechange")}} 事件被这些接口实现的对象(如 {{domxref("Window")}}、{{domxref("HTMLBodyElement")}} 或者 {{domxref("HTMLIFrameElement")}} 等对象)触发时,该事件属性的代码将被运行。这样的事件在浏览器通知更佳的语言列表已被更新后被触发。关于语言列表的介绍,您可访问:{{domxref("NavigatorLanguage.languages")}}。</p> + +<h2 id="语法">语法</h2> + +<pre class="eval"><em>object</em>.onlanguagechange = <em>function</em>; +</pre> + +<h3 id="值">值</h3> + +<ul> + <li><code>function</code> 是用户定义的函数的名字 ,不需要 <code>()</code> 的后缀或者任何形式参数, 或者是匿名函数,例如 <code>function(event) {...}</code>。事件处理程序总是有一个单一的形式参数,包含一个事件,这里有它的类型 {{domxref("Event")}}.</li> +</ul> + +<h2 id="例子">例子</h2> + +<pre class="brush: js">window.onlanguagechange = function(ev) { alert("languagechange event detected!"); }; +</pre> + +<h2 id="Specifications" name="Specifications">标准</h2> + +<table class="standard-table" style="height: 49px; width: 1000px;"> + <thead> + <tr> + <th scope="col">标准</th> + <th scope="col">状态</th> + <th scope="col">备注</th> + </tr> + </thead> + <tbody> + <tr> + <td>{{ SpecName('HTML WHATWG', '#handler-workerglobalscope-onlanguagechange', 'WindowEventHandler.onlanguagechange') }}</td> + <td>{{ Spec2('HTML WHATWG') }}</td> + <td>初始版本</td> + </tr> + </tbody> +</table> + +<h2 id="浏览器兼容性">浏览器兼容性</h2> + +<p>{{ CompatibilityTable() }}</p> + +<div id="compat-desktop"> +<table class="compat-table"> + <tbody> + <tr> + <th>Feature</th> + <th>Chrome</th> + <th>Firefox (Gecko)</th> + <th>Internet Explorer</th> + <th>Opera</th> + <th>Safari</th> + </tr> + <tr> + <td>基础支持</td> + <td>{{ CompatUnknown() }}</td> + <td>{{ CompatGeckoDesktop(32.0) }}</td> + <td>{{ CompatNo() }}</td> + <td>{{ CompatUnknown() }}</td> + <td>{{ CompatUnknown() }}</td> + </tr> + </tbody> +</table> +</div> + +<div id="compat-mobile"> +<table class="compat-table"> + <tbody> + <tr> + <th>Feature</th> + <th>Android</th> + <th>Chrome for Android</th> + <th>Firefox Mobile (Gecko)</th> + <th>IE Mobile</th> + <th>Opera Mobile</th> + <th>Safari Mobile</th> + </tr> + <tr> + <td>基础支持</td> + <td>{{ CompatUnknown() }}</td> + <td>{{ CompatUnknown() }}</td> + <td>{{ CompatGeckoMobile(32.0) }}</td> + <td>{{ CompatNo() }}</td> + <td>{{ CompatUnknown() }}</td> + <td>{{ CompatUnknown() }}</td> + </tr> + </tbody> +</table> +</div> + +<h2 id="参见">参见</h2> + +<ul> + <li>{{event("languagechange")}} 事件和它的类型 {{domxref("Event")}}。</li> +</ul> |