diff options
Diffstat (limited to 'files/zh-cn/web/api/notification')
-rw-r--r-- | files/zh-cn/web/api/notification/actions/index.html | 84 | ||||
-rw-r--r-- | files/zh-cn/web/api/notification/badge/index.html | 54 | ||||
-rw-r--r-- | files/zh-cn/web/api/notification/body/index.html | 99 | ||||
-rw-r--r-- | files/zh-cn/web/api/notification/close/index.html | 84 | ||||
-rw-r--r-- | files/zh-cn/web/api/notification/data/index.html | 96 | ||||
-rw-r--r-- | files/zh-cn/web/api/notification/dir/index.html | 99 | ||||
-rw-r--r-- | files/zh-cn/web/api/notification/index.html | 76 | ||||
-rw-r--r-- | files/zh-cn/web/api/notification/notification/index.html | 213 | ||||
-rw-r--r-- | files/zh-cn/web/api/notification/permission/index.html | 99 | ||||
-rw-r--r-- | files/zh-cn/web/api/notification/requestpermission/index.html | 102 |
10 files changed, 10 insertions, 996 deletions
diff --git a/files/zh-cn/web/api/notification/actions/index.html b/files/zh-cn/web/api/notification/actions/index.html index 0646fd416d..587137cc13 100644 --- a/files/zh-cn/web/api/notification/actions/index.html +++ b/files/zh-cn/web/api/notification/actions/index.html @@ -41,89 +41,7 @@ translation_of: Web/API/Notification/actions <h2 id="浏览器兼容性">浏览器兼容性</h2> -<div>{{CompatibilityTable}}</div> - -<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>Basic support</td> - <td>{{CompatChrome(53)}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatOpera(40)}}</td> - <td>{{CompatUnknown}}</td> - </tr> - <tr> - <td>Available in workers</td> - <td>{{CompatChrome(53)}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatOpera(40)}}</td> - <td>{{CompatUnknown}}</td> - </tr> - </tbody> -</table> -</div> - -<div id="compat-mobile"> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Android Webview</th> - <th>Chrome for Android</th> - <th>Firefox Mobile (Gecko)</th> - <th>Firefox OS</th> - <th>IE Mobile</th> - <th>Opera Mobile</th> - <th>Safari Mobile</th> - </tr> - <tr> - <td>Basic support</td> - <td> - <p>{{CompatNo}}</p> - </td> - <td>{{CompatChrome(53)}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatOperaMobile(40)}}</td> - <td>{{CompatUnknown}}</td> - </tr> - <tr> - <td>Available in workers</td> - <td>{{CompatNo}}</td> - <td>{{CompatChrome(53)}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatOperaMobile(40)}}</td> - <td>{{CompatUnknown}}</td> - </tr> - </tbody> -</table> -</div> - -<h3 id="Firefox_OS_相关">Firefox OS 相关</h3> - -<p>{{Page("/en-US/docs/Web/API/Notifications_API", "Firefox OS notes")}}</p> - -<h3 id="Chrome_相关">Chrome 相关</h3> - -<p>{{Page("/en-US/docs/Web/API/Notifications_API", "Chrome notes")}}</p> - -<h3 id="Safari_相关">Safari 相关</h3> - -<p>{{Page("/en-US/docs/Web/API/Notifications_API", "Safari notes")}}</p> +{{Compat("api.Notification.actions")}} <h2 id="更多">更多</h2> diff --git a/files/zh-cn/web/api/notification/badge/index.html b/files/zh-cn/web/api/notification/badge/index.html index 9858d6424c..ad026404f5 100644 --- a/files/zh-cn/web/api/notification/badge/index.html +++ b/files/zh-cn/web/api/notification/badge/index.html @@ -39,56 +39,4 @@ translation_of: Web/API/Notification/badge <h2 id="浏览器兼容性">浏览器兼容性</h2> -<div>{{CompatibilityTable}}</div> - -<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 (WebKit)</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{CompatChrome(53.0)}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatOpera(39)}}</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>Android Webview</th> - <th>Firefox Mobile (Gecko)</th> - <th>Firefox OS</th> - <th>IE Mobile</th> - <th>Opera Mobile</th> - <th>Safari Mobile</th> - <th>Chrome for Android</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{CompatNo}}</td> - <td>{{CompatChrome(53.0)}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatOperaMobile(39)}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatChrome(53.0)}}</td> - </tr> - </tbody> -</table> -</div> +{{Compat("api.Notification.badge")}} diff --git a/files/zh-cn/web/api/notification/body/index.html b/files/zh-cn/web/api/notification/body/index.html index 02ada837d2..7e1f9ef24f 100644 --- a/files/zh-cn/web/api/notification/body/index.html +++ b/files/zh-cn/web/api/notification/body/index.html @@ -49,104 +49,7 @@ translation_of: Web/API/Notification/body <h2 id="浏览器兼容性">浏览器兼容性</h2> -<div>{{CompatibilityTable}}</div> - -<div id="compat-desktop"> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Chrome</th> - <th>Edge</th> - <th>Firefox (Gecko)</th> - <th>Internet Explorer</th> - <th>Opera</th> - <th>Safari</th> - </tr> - <tr> - <td>Basic support</td> - <td>5 {{ property_prefix("webkit") }} (see notes)<br> - 22</td> - <td>{{CompatVersionUnknown}}</td> - <td>4.0 {{ property_prefix("moz") }} (see notes)<br> - 22</td> - <td>{{ CompatNo() }}</td> - <td>25</td> - <td>6 (see notes)</td> - </tr> - <tr> - <td>Available in workers</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatGeckoDesktop("41.0")}}</td> - <td>{{CompatUnknown}}</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>Android Webview</th> - <th>Edge</th> - <th>Firefox Mobile (Gecko)</th> - <th>Firefox OS</th> - <th>IE Mobile</th> - <th>Opera Mobile</th> - <th>Safari Mobile</th> - <th>Chrome for Android</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{ CompatUnknown() }}</td> - <td> - <p>{{CompatVersionUnknown}}</p> - </td> - <td>{{CompatVersionUnknown}}</td> - <td>4.0 {{ property_prefix("moz") }} (see notes)<br> - 22</td> - <td>1.0.1 {{ property_prefix("moz") }} (see notes)<br> - 1.2</td> - <td>{{ CompatNo() }}</td> - <td>{{ CompatUnknown() }}</td> - <td>{{ CompatNo() }}</td> - <td> - <p>{{CompatVersionUnknown}}</p> - </td> - </tr> - <tr> - <td>Available in workers</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatGeckoMobile(41.0)}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - </tr> - </tbody> -</table> -</div> - -<h3 id="Firefox_OS_备忘">Firefox OS 备忘</h3> - -<p>{{Page("/en-US/docs/Web/API/Notifications_API", "Firefox OS notes")}}</p> - -<h3 id="Chrome_备忘">Chrome 备忘</h3> - -<p>{{Page("/en-US/docs/Web/API/Notifications_API", "Chrome notes")}}</p> - -<h3 id="Safari_备忘">Safari 备忘</h3> - -<p>{{Page("/en-US/docs/Web/API/Notifications_API", "Safari notes")}}</p> +{{Compat("api.Notification.body")}} <h2 id="相关链接">相关链接</h2> diff --git a/files/zh-cn/web/api/notification/close/index.html b/files/zh-cn/web/api/notification/close/index.html index 294360572c..3e9fed617c 100644 --- a/files/zh-cn/web/api/notification/close/index.html +++ b/files/zh-cn/web/api/notification/close/index.html @@ -55,89 +55,7 @@ translation_of: Web/API/Notification/close <h2 id="Browser_compatibility">Browser compatibility</h2> -<p>{{CompatibilityTable}}</p> - -<div id="compat-desktop"> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Chrome</th> - <th>Edge</th> - <th>Firefox (Gecko)</th> - <th>Internet Explorer</th> - <th>Opera</th> - <th>Safari</th> - </tr> - <tr> - <td>Basic support</td> - <td>5{{property_prefix("webkit")}}<sup>[1]</sup><br> - 22</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatGeckoDesktop("2.0")}}{{property_prefix("moz")}}<sup>[2]</sup><br> - {{CompatGeckoDesktop("22.0")}}</td> - <td>{{CompatNo}}</td> - <td>25</td> - <td>6<sup>[3]</sup></td> - </tr> - </tbody> -</table> -</div> - -<div id="compat-mobile"> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Android</th> - <th>Android Webview</th> - <th>Edge</th> - <th>Firefox Mobile (Gecko)</th> - <th>Firefox OS</th> - <th>IE Mobile</th> - <th>Opera Mobile</th> - <th>Safari Mobile</th> - <th>Chrome for Android</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{CompatUnknown}}</td> - <td> - <p>{{CompatVersionUnknown}}</p> - </td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatGeckoMobile(4.0)}}{{property_prefix("moz")}}<sup>[2]</sup><br> - {{CompatGeckoMobile(22.0)}}</td> - <td>1.0.1{{property_prefix("moz")}}<sup>[2]</sup><br> - 1.2</td> - <td>{{CompatNo}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatNo}}</td> - <td> - <p>{{CompatVersionUnknown}}</p> - </td> - </tr> - </tbody> -</table> -</div> - -<p>[1] Before Chrome 22, the support for notification followed an <a href="http://www.chromium.org/developers/design-documents/desktop-notifications/api-specification">old prefixed version of the specification</a> and used the {{domxref("window.navigator.webkitNotifications","navigator.webkitNotifications")}} object to instantiate a new notification.</p> - -<p>Before Chrome 32, {{domxref("Notification.permission")}} was not supported.</p> - -<p>Before Chrome 42, service worker additions were not supported.</p> - -<p>[2] Prior to Firefox 22 (Firefox OS <1.2), the instantiation of a new notification must be done with the {{domxref("window.navigator.mozNotification", "navigator.mozNotification")}} object through its <code>createNotification</code> method.</p> - -<p>Prior to Firefox 22 (Firefox OS <1.2), the Notification was displayed when calling the <code>show</code> method and supported only the <code>click</code> and <code>close</code> events.</p> - -<p>Nick Desaulniers wrote a <a href="https://github.com/nickdesaulniers/fxos-irc/blob/master/js/notification.js">Notification shim</a> to cover both newer and older implementations.</p> - -<p>One particular Firefox OS issue is that you can <a href="https://github.com/nickdesaulniers/fxos-irc/blob/0160cf6c3a2b5c9fe33822aaf6bcba3b7e846da9/my.js#L171">pass a path to an icon</a> to use in the notification, but if the app is packaged you cannot use a relative path like <code>/my_icon.png</code>. You also can't use <code>window.location.origin + "/my_icon.png"</code> because <code>window.location.origin</code> is null in packaged apps. The <a href="https://developer.mozilla.org/en-US/Apps/Developing/Manifest#origin">manifest origin field</a> fixes this, but it is only available in Firefox OS 1.1+. A potential solution for supporting Firefox OS <1.1 is to <a href="https://github.com/nickdesaulniers/fxos-irc/blob/0160cf6c3a2b5c9fe33822aaf6bcba3b7e846da9/my.js#L168">pass an absolute URL to an externally hosted version of the icon</a>. This is less than ideal as the notification is displayed immediately without the icon, then the icon is fetched, but it works on all versions of Firefox OS.</p> - -<p>When using notifications in a Firefox OS app, be sure to add the <code>desktop-notification</code> permission in your manifest file. Notifications can be used at any permission level, hosted or above: <code>"permissions": { "desktop-notification": {} }</code></p> - -<p>[3] Safari started to support notification with Safari 6, but only on Mac OSX 10.8+ (Mountain Lion).</p> +{{Compat("api.Notification.close")}} <h2 id="See_also">See also</h2> diff --git a/files/zh-cn/web/api/notification/data/index.html b/files/zh-cn/web/api/notification/data/index.html index b7426d601e..d4d3c44a55 100644 --- a/files/zh-cn/web/api/notification/data/index.html +++ b/files/zh-cn/web/api/notification/data/index.html @@ -62,101 +62,7 @@ n.data // should return 'I like peas.'</pre> <h2 id="Browser_compatibility">Browser compatibility</h2> -<p>{{ CompatibilityTable() }}</p> - -<div id="compat-desktop"> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Chrome</th> - <th>Edge</th> - <th>Firefox (Gecko)</th> - <th>Internet Explorer</th> - <th>Opera</th> - <th>Safari</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{CompatChrome(44)}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{ CompatNo() }}</td> - <td>{{ CompatNo() }}</td> - <td>{{CompatOpera(34)}}</td> - <td>{{ CompatNo() }}</td> - </tr> - <tr> - <td>Available in workers</td> - <td>{{CompatChrome(44)}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatGeckoDesktop("41.0")}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatOpera(34)}}</td> - <td>{{CompatUnknown}}</td> - </tr> - <tr> - <td>Secure contexts only</td> - <td>{{CompatChrome(62)}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatOpera(49)}}</td> - <td>{{CompatUnknown}}</td> - </tr> - </tbody> -</table> -</div> - -<div id="compat-mobile"> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Android Webview</th> - <th>Chrome for Android</th> - <th>Edge</th> - <th>Firefox Mobile (Gecko)</th> - <th>Firefox OS</th> - <th>IE Mobile</th> - <th>Opera Mobile</th> - <th>Safari Mobile</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{ CompatNo() }}</td> - <td>{{CompatChrome(44)}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{ CompatNo() }}</td> - <td>{{ CompatNo() }}</td> - <td>{{ CompatNo() }}</td> - <td>{{CompatOperaMobile(34)}}</td> - <td>{{ CompatNo() }}</td> - </tr> - <tr> - <td>Available in workers</td> - <td>{{ CompatNo() }}</td> - <td>{{CompatChrome(44)}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatGeckoMobile(41.0)}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatOperaMobile(34)}}</td> - <td>{{CompatUnknown}}</td> - </tr> - <tr> - <td>Secure contexts only</td> - <td>{{ CompatNo() }}</td> - <td>{{CompatChrome(62)}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatOperaMobile(49)}}</td> - <td>{{CompatUnknown}}</td> - </tr> - </tbody> -</table> -</div> +{{Compat("api.Notification.data")}} <h2 id="See_also">See also</h2> diff --git a/files/zh-cn/web/api/notification/dir/index.html b/files/zh-cn/web/api/notification/dir/index.html index 51d64db69c..c5c1c2e997 100644 --- a/files/zh-cn/web/api/notification/dir/index.html +++ b/files/zh-cn/web/api/notification/dir/index.html @@ -61,104 +61,7 @@ n.dir // 应该返回 'rtl' <h2 id="浏览器兼容性">浏览器兼容性</h2> -<p>{{ CompatibilityTable() }}</p> - -<div id="compat-desktop"> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Chrome</th> - <th>Edge</th> - <th>Firefox (Gecko)</th> - <th>Internet Explorer</th> - <th>Opera</th> - <th>Safari</th> - </tr> - <tr> - <td>基础支持</td> - <td>5 {{ property_prefix("webkit") }} (看提示)<br> - 22</td> - <td>{{CompatVersionUnknown}}</td> - <td>4.0 {{ property_prefix("moz") }} (看提示)<br> - 22</td> - <td>{{ CompatNo() }}</td> - <td>25</td> - <td>6 (看提示)</td> - </tr> - <tr> - <td>Available in workers</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatGeckoDesktop("41.0")}}</td> - <td>{{CompatUnknown}}</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>Android Webview</th> - <th>Edge</th> - <th>Firefox Mobile (Gecko)</th> - <th>Firefox OS</th> - <th>IE Mobile</th> - <th>Opera Mobile</th> - <th>Safari Mobile</th> - <th>Chrome for Android</th> - </tr> - <tr> - <td>基础支持</td> - <td>{{ CompatUnknown() }}</td> - <td> - <p>{{CompatVersionUnknown}}</p> - </td> - <td>{{CompatVersionUnknown}}</td> - <td>4.0 {{ property_prefix("moz") }} (看注释)<br> - 22</td> - <td>1.0.1 {{ property_prefix("moz") }} (看注释)<br> - 1.2</td> - <td>{{ CompatNo() }}</td> - <td>{{ CompatUnknown() }}</td> - <td>{{ CompatNo() }}</td> - <td> - <p>{{CompatVersionUnknown}}</p> - </td> - </tr> - <tr> - <td>能在Worker里调用</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatGeckoMobile(41.0)}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - </tr> - </tbody> -</table> -</div> - -<h3 id="Firefox_OS_提示">Firefox OS 提示</h3> - -<p>{{Page("/en-US/docs/Web/API/Notifications_API", "Firefox OS notes")}}</p> - -<h3 id="Chrome_提示">Chrome 提示</h3> - -<p>{{Page("/en-US/docs/Web/API/Notifications_API", "Chrome notes")}}</p> - -<h3 id="Safari_提示">Safari 提示</h3> - -<p>{{Page("/en-US/docs/Web/API/Notifications_API", "Safari notes")}}</p> +{{Compat("api.Notification.dir")}} <h2 id="参见">参见</h2> diff --git a/files/zh-cn/web/api/notification/index.html b/files/zh-cn/web/api/notification/index.html index 1c85a11bca..c80d973d9d 100644 --- a/files/zh-cn/web/api/notification/index.html +++ b/files/zh-cn/web/api/notification/index.html @@ -174,81 +174,7 @@ translation_of: Web/API/Notification <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>Basic support</td> - <td>5 {{ property_prefix("webkit") }} (see notes)<br> - 22</td> - <td>4.0 {{ property_prefix("moz") }} (see notes)<br> - 22</td> - <td>{{ CompatNo() }}</td> - <td>25</td> - <td>6 (see notes)</td> - </tr> - </tbody> -</table> -</div> - -<div id="compat-mobile"> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Android</th> - <th>Firefox Mobile (Gecko)</th> - <th>Firefox OS</th> - <th>IE Mobile</th> - <th>Opera Mobile</th> - <th>Safari Mobile</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{ CompatUnknown() }}</td> - <td>4.0 {{ property_prefix("moz") }} (see notes)<br> - 22</td> - <td>1.0.1 {{ property_prefix("moz") }} (see notes)<br> - 1.2</td> - <td>{{ CompatNo() }}</td> - <td>{{ CompatUnknown() }}</td> - <td>{{ CompatNo() }}</td> - </tr> - </tbody> -</table> -</div> - -<h3 id="Gecko_备忘">Gecko 备忘</h3> - -<ul> - <li>在 Firefox 22 (Firefox OS <1.2) 之前,创建一个新的通知必须使用 {{ domxref("window.navigator.mozNotification","navigator.mozNotification") }} 对象的 <code>createNotification</code> 方法。</li> - <li>在 Firefox 22 (Firefox OS <1.2) 之前,当调用 <code>show</code> 方法时通知才会被显示出来,并且只支持 <code>click</code> 和 <code>close</code> 事件。</li> - <li>Nick Desaulniers 编写了一个 <a href="https://github.com/nickdesaulniers/fxos-irc/blob/master/js/notification.js">Notification shim</a> 以向前和向后兼容各种版本的实现。</li> - <li>在 Firefox OS 有个特别的问题, <a href="https://github.com/nickdesaulniers/fxos-irc/blob/0160cf6c3a2b5c9fe33822aaf6bcba3b7e846da9/my.js#L171">你可以传递一个图标路径</a> 用于通知,但是如果应用被打包了你就不能使用相对路径,比如: <code>/my_icon.png</code>。同样的,你也不能这样用: <code>window.location.origin + "/my_icon.png"</code>,<code>因为 window.location.origin</code> 的值在打包的应用里为 null。 <a href="https://developer.mozilla.org/en-US/Apps/Developing/Manifest#origin">清单来源字段</a> 可以修复这个问题,但是这个方法只在 Firefox OS 1.1+ 版本中有效。不过有个潜在的解决方案可以用于 Firefox OS <1.1 版本,就是 <a href="https://github.com/nickdesaulniers/fxos-irc/blob/0160cf6c3a2b5c9fe33822aaf6bcba3b7e846da9/my.js#L168">传递图标的位于外部服务器的绝对 URL</a> 。这个方案并不理想,如通知要立即显示而没有图标,那么将会请求服务器,但是可以用于所有版本的 Firefox OS。</li> -</ul> - -<h3 id="Chrome_备忘">Chrome 备忘</h3> - -<ul> - <li>在 Chrome 22 版本之前,如果要使用通知需要 <a href="http://www.chromium.org/developers/design-documents/desktop-notifications/api-specification">旧的带前缀版本的规范</a> ,并且使用{{domxref("window.navigator.webkitNotifications","navigator.webkitNotifications")}} 对象创建一个新的通知实例。</li> - <li>在 Chrome 32 版本之前,不支持 {{domxref("Notification.permission")}} 属性。</li> -</ul> - -<h3 id="Safari_备忘">Safari 备忘</h3> - -<ul> - <li>Safari 在 Safari 6 版本开始支持通知,但是只能在 Mac OSX 10.8+ (Mountain Lion) 中使用。</li> -</ul> +{{Compat("api.Notification")}} <h2 id="请参见">请参见</h2> diff --git a/files/zh-cn/web/api/notification/notification/index.html b/files/zh-cn/web/api/notification/notification/index.html index a4954e446a..b6cae7a74d 100644 --- a/files/zh-cn/web/api/notification/notification/index.html +++ b/files/zh-cn/web/api/notification/notification/index.html @@ -81,218 +81,7 @@ translation_of: Web/API/Notification/Notification <h2 id="Browser_compatibility">Browser compatibility</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>Basic support</td> - <td>5 {{ property_prefix("webkit") }} (see notes)<br> - 22</td> - <td>4.0 {{ property_prefix("moz") }} (see notes)<br> - 22</td> - <td>{{ CompatNo() }}</td> - <td>25</td> - <td>6 (see notes)</td> - </tr> - <tr> - <td>Available in workers</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatGeckoDesktop("41.0")}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - </tr> - <tr> - <td><code>icon</code> option</td> - <td>5 {{ property_prefix("webkit") }} (see notes)<br> - 22</td> - <td>4.0 {{ property_prefix("moz") }} (see notes)<br> - 22</td> - <td>{{ CompatNo() }}</td> - <td>25</td> - <td>{{ CompatNo() }}</td> - </tr> - <tr> - <td><font face="Consolas, Liberation Mono, Courier, monospace">vibrate</font></td> - <td>{{CompatChrome(45.0)}}</td> - <td>{{ CompatNo() }}</td> - <td>{{ CompatNo() }}</td> - <td>{{ CompatNo() }}</td> - <td>{{ CompatNo() }}</td> - </tr> - <tr> - <td><code>requireInteraction</code></td> - <td>{{CompatChrome(47.0)}}</td> - <td> </td> - <td> </td> - <td>32</td> - <td> </td> - </tr> - <tr> - <td><code>renotify</code></td> - <td>{{CompatChrome(50.0)}}</td> - <td> </td> - <td> </td> - <td> </td> - <td> </td> - </tr> - <tr> - <td><code>badge</code></td> - <td>{{compatChrome(53.0)}}</td> - <td> </td> - <td> </td> - <td>{{CompatOpera(39.0)}}</td> - <td> </td> - </tr> - <tr> - <td><code>image</code></td> - <td>{{compatChrome(55.0)}}</td> - <td> </td> - <td> </td> - <td>{{CompatUnknown}}</td> - <td> </td> - </tr> - </tbody> -</table> -</div> - -<div id="compat-mobile"> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Android</th> - <th>Android Webview</th> - <th>Firefox Mobile (Gecko)</th> - <th>Firefox OS</th> - <th>IE Mobile</th> - <th>Opera Mobile</th> - <th>Safari Mobile</th> - <th>Chrome for Android</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{ CompatUnknown() }}</td> - <td> - <p>{{CompatVersionUnknown}}</p> - </td> - <td>4.0 {{ property_prefix("moz") }} (see notes)<br> - 22</td> - <td>1.0.1 {{ property_prefix("moz") }} (see notes)<br> - 1.2</td> - <td>{{ CompatNo() }}</td> - <td>{{ CompatUnknown() }}</td> - <td>{{ CompatNo() }}</td> - <td> - <p>{{CompatVersionUnknown}}</p> - </td> - </tr> - <tr> - <td>Available in workers</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatGeckoMobile(41.0)}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - </tr> - <tr> - <td>icon option</td> - <td>{{ CompatUnknown() }}</td> - <td>{{CompatVersionUnknown}}</td> - <td>4.0 {{ property_prefix("moz") }} (see notes)<br> - 22</td> - <td>1.0.1 {{ property_prefix("moz") }} (see notes)<br> - 1.2</td> - <td>{{ CompatNo() }}</td> - <td>{{ CompatUnknown() }}</td> - <td>{{ CompatNo() }}</td> - <td>{{CompatVersionUnknown}}</td> - </tr> - <tr> - <td><font face="Consolas, Liberation Mono, Courier, monospace">vibrate</font></td> - <td>{{ CompatNo() }}</td> - <td>{{CompatChrome(45.0)}}</td> - <td>{{ CompatNo() }}</td> - <td>{{ CompatNo() }}</td> - <td>{{ CompatNo() }}</td> - <td>32</td> - <td>{{ CompatNo() }}</td> - <td>{{CompatChrome(45.0)}}</td> - </tr> - <tr> - <td><code>requireInteraction</code></td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td> </td> - <td> </td> - <td> </td> - <td> </td> - <td> </td> - <td>{{CompatNo}}</td> - </tr> - <tr> - <td><code>renotify</code></td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td> </td> - <td> </td> - <td> </td> - <td> </td> - <td> </td> - <td>{{CompatChrome(50.0)}}</td> - </tr> - <tr> - <td><code>badge</code></td> - <td>{{CompatNo}}</td> - <td>{{compatChrome(53.0)}}</td> - <td> </td> - <td> </td> - <td> </td> - <td>{{CompatOperaMobile(39.0)}}</td> - <td> </td> - <td>{{compatChrome(53.0)}}</td> - </tr> - <tr> - <td><code>image</code></td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td> </td> - <td> </td> - <td> </td> - <td>{{CompatUnknown}}</td> - <td> </td> - <td>{{compatChrome(55.0)}}</td> - </tr> - </tbody> -</table> -</div> - -<h3 id="Firefox_OS_notes">Firefox OS notes</h3> - -<p>{{Page("/en-US/docs/Web/API/Notifications_API", "Firefox OS notes")}}</p> - -<h3 id="Chrome_notes">Chrome notes</h3> - -<p>Starting in Chrome 49, notifications do not work in incognito mode.</p> - -<p>{{Page("/en-US/docs/Web/API/Notifications_API", "Chrome notes")}}</p> - -<h3 id="Safari_notes">Safari notes</h3> - -<p>{{Page("/en-US/docs/Web/API/Notifications_API", "Safari notes")}}</p> +{{Compat("api.Notification.Notification")}} <h2 id="See_also">See also</h2> diff --git a/files/zh-cn/web/api/notification/permission/index.html b/files/zh-cn/web/api/notification/permission/index.html index 7cd16cf9d1..3ace633ea6 100644 --- a/files/zh-cn/web/api/notification/permission/index.html +++ b/files/zh-cn/web/api/notification/permission/index.html @@ -72,104 +72,7 @@ translation_of: Web/API/Notification/permission <h2 id="Browser_compatibility">Browser compatibility</h2> -<p>{{ CompatibilityTable() }}</p> - -<div id="compat-desktop"> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Chrome</th> - <th>Edge</th> - <th>Firefox (Gecko)</th> - <th>Internet Explorer</th> - <th>Opera</th> - <th>Safari</th> - </tr> - <tr> - <td>Basic support</td> - <td>5 {{ property_prefix("webkit") }} (see notes)<br> - 22</td> - <td>{{CompatVersionUnknown}}</td> - <td>4.0 {{ property_prefix("moz") }} (see notes)<br> - 22</td> - <td>{{ CompatNo() }}</td> - <td>25</td> - <td>6 (see notes)</td> - </tr> - <tr> - <td>Available in workers</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatGeckoDesktop("41.0")}}</td> - <td>{{CompatUnknown}}</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>Android Webview</th> - <th>Edge</th> - <th>Firefox Mobile (Gecko)</th> - <th>Firefox OS</th> - <th>IE Mobile</th> - <th>Opera Mobile</th> - <th>Safari Mobile</th> - <th>Chrome for Android</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{ CompatUnknown() }}</td> - <td> - <p>{{CompatVersionUnknown}}</p> - </td> - <td>{{CompatVersionUnknown}}</td> - <td>4.0 {{ property_prefix("moz") }} (see notes)<br> - 22</td> - <td>1.0.1 {{ property_prefix("moz") }} (see notes)<br> - 1.2</td> - <td>{{ CompatNo() }}</td> - <td>{{ CompatUnknown() }}</td> - <td>{{ CompatNo() }}</td> - <td> - <p>{{CompatVersionUnknown}}</p> - </td> - </tr> - <tr> - <td>Available in workers</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatGeckoMobile(41.0)}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - </tr> - </tbody> -</table> -</div> - -<h3 id="Firefox_OS_notes">Firefox OS notes</h3> - -<p>{{Page("/en-US/docs/Web/API/Notifications_API", "Firefox OS notes")}}</p> - -<h3 id="Chrome_notes">Chrome notes</h3> - -<p>{{Page("/en-US/docs/Web/API/Notifications_API", "Chrome notes")}}</p> - -<h3 id="Safari_notes">Safari notes</h3> - -<p>{{Page("/en-US/docs/Web/API/Notifications_API", "Safari notes")}}</p> +{{Compat("api.Notification.permission")}} <h2 id="See_also">See also</h2> diff --git a/files/zh-cn/web/api/notification/requestpermission/index.html b/files/zh-cn/web/api/notification/requestpermission/index.html index 90b3efebff..f49bc4b494 100644 --- a/files/zh-cn/web/api/notification/requestpermission/index.html +++ b/files/zh-cn/web/api/notification/requestpermission/index.html @@ -65,107 +65,7 @@ translation_of: Web/API/Notification/requestPermission <h2 id="浏览器兼容性">浏览器兼容性</h2> -<p>{{CompatibilityTable}}</p> - -<div id="compat-desktop"> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Chrome</th> - <th>Edge</th> - <th>Firefox (Gecko)</th> - <th>Internet Explorer</th> - <th>Opera</th> - <th>Safari</th> - </tr> - <tr> - <td>Basic support</td> - <td>5{{property_prefix("webkit")}}<sup>[1]</sup><br> - 22</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatGeckoDesktop("2.0")}}{{property_prefix("moz")}}<sup>[2]</sup><br> - {{CompatGeckoDesktop("22.0")}}</td> - <td>{{CompatNo}}</td> - <td>25</td> - <td>6<sup>[3]</sup></td> - </tr> - <tr> - <td>promise-based version</td> - <td>{{CompatChrome(46.0)}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatGeckoDesktop("47.0")}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatOpera(40)}}</td> - <td>{{CompatNo}}</td> - </tr> - </tbody> -</table> -</div> - -<div id="compat-mobile"> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Android</th> - <th>Android Webview</th> - <th>Edge</th> - <th>Firefox Mobile (Gecko)</th> - <th>Firefox OS</th> - <th>IE Mobile</th> - <th>Opera Mobile</th> - <th>Safari Mobile</th> - <th>Chrome for Android</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatGeckoMobile("2.0")}}{{property_prefix("moz")}}<sup>[2]</sup><br> - {{CompatGeckoMobile("22.0")}}</td> - <td>1.0.1{{property_prefix("moz")}}<sup>[2]</sup><br> - 1.2</td> - <td>{{CompatNo}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatVersionUnknown}}</td> - </tr> - <tr> - <td>promise-based version</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatGeckoMobile("47.0")}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - </tr> - </tbody> -</table> -</div> - -<p>[1] 在 Chrome 22 之前,对于通知的支持请参考 <a href="http://www.chromium.org/developers/design-documents/desktop-notifications/api-specification">old prefixed version of the specification</a> 它使用 {{domxref("window.navigator.webkitNotifications","navigator.webkitNotifications")}} 对象去实例化一个新的通知。</p> - -<p>在 Chrome 32 之前,不支持 {{domxref("Notification.permission")}} 。</p> - -<p>在 Chrome 42 之前,不支持在 service worker 中使用这个API。</p> - -<p>[2] 对于 Firefox 22 之前的版本 (Firefox OS <1.2),实例化一个新的通知必须使用 {{domxref("window.navigator.mozNotification", "navigator.mozNotification")}} 对象中的 <code>createNotification</code> 方法.</p> - -<p>对于 Firefox 22 之前的版本 (Firefox OS <1.2),通知只会在 <code>show</code> 方法被调用后显示,而且只支持 <code>click</code> 和 <code>close</code> 事件。</p> - -<p>Nick Desaulniers 写了一个 <a href="https://github.com/nickdesaulniers/fxos-irc/blob/master/js/notification.js">Notification shim</a> 来同时兼容新旧两种写法。</p> - -<p>在 Firefox OS 上有一个特殊的问题是:虽然你可以在通知中使用 <a href="https://github.com/nickdesaulniers/fxos-irc/blob/0160cf6c3a2b5c9fe33822aaf6bcba3b7e846da9/my.js#L171">包含路径的图标</a> ,但是如果应用被打包了,你就不能使用形如 <code>/my_icon.png</code> 这样的相对路径。当然你也不能使用<code>window.location.origin + "/my_icon.png"</code> ,因为 <code>window.location.origin</code> 在打包的应用中的值是<code>null</code>。<a href="https://developer.mozilla.org/en-US/Apps/Developing/Manifest#origin">manifest origin field</a> 修复了这个问题,但是它只能在 Firefox OS 1.1+ 中使用。一个潜在的支持 Firefox OS <1.1 的解决方案是 <a href="https://github.com/nickdesaulniers/fxos-irc/blob/0160cf6c3a2b5c9fe33822aaf6bcba3b7e846da9/my.js#L168">传递一个指向外部部署的图标的绝对路径的URL</a>。这并不是一个理想的解决方案,因为这将导致通知以无图标的形式出现,然后图标才会被获取,但是这个方法适用于所有版本的 Firefox OS.</p> - -<p>在 Firefox OS app 中使用通知的时候,确保添加 <code>desktop-notification</code> 权限到你的 manifest 文件中。通知即可在任何权限等级,外部部署或者像下面这样 <code>"permissions": { "desktop-notification": {} }</code> 的情况下使用。</p> - -<p>[3] Safari 在 Safari 6 之后支持通知,但是只能在 Mac OSX 10.8+ (Mountain Lion) 中使用。</p> +{{Compat("api.Notification.requestPermission")}} <h2 id="参见">参见</h2> |