Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Navigator.mozSetMessageHandler()

这篇翻译不完整。请帮忙从英语翻译这篇文章

概要

该方法用来允许应用为系统消息注册处理程序,对消息作出反应。

任何应用都允许注册到任何消息,但一些消息仅仅可以被送到有对应接收权限的应用。不同于DOM事件,如果应用没有针对系统消息的处理程序,它们将留在队列里。如果有排队消息,可以传入一个type参数调用navigator.mozHasPendingMessage()查看,当一个处理程序被设置,待处理消息将异步的地发送到应用。

语法

navigator.mozSetMessageHandler(type, handler);

参数

 
type
type是一个字符串,表示要为其注册处理函数的一类消息。
handler
当系统发送消息时,该处理函数被调用,其接收参数由消息类型来确定。

消息类型

目前Firefox OS允许注册以下消息 :

Message name Handler signature Permission
activity f( MozActivityRequestHandler request )  
alarm f( object unknown ) alarms
bluetooth-cancel f( object unknown ) bluetooth
bluetooth-dialer-command f( object unknown ) bluetooth
bluetooth-hfp-status-changed f( object unknown ) bluetooth
bluetooth-opp-transfer-start f( object unknown ) bluetooth
bluetooth-opp-transfer-complete f( object unknown ) bluetooth
bluetooth-opp-receiving-file-confirmation f( object unknown ) bluetooth
bluetooth-opp-update-progress f( object unknown ) bluetooth
bluetooth-pairedstatuschanged f( object unknown ) bluetooth
bluetooth-requestconfirmation f( object unknown ) bluetooth
bluetooth-requestpincode f( object unknown ) bluetooth
bluetooth-requestpasskey f( object unknown ) bluetooth
headset-button f( object unknown )  
icc-stkcommand f( object command ) settings
notification f( object unknown )  
push f( object registration ) push
push-register f (  ) push
sms-received f( SmsMessage sms ) sms
sms-sent f( SmsMessage sms ) sms
telephony-call-ended f( object call ) telephony
telephony-new-call f( ) telephony
ussd-received f( object ussd ) mobileconnection
wappush-received f( object wappush ) wappush

规范说明

Specification Status Comment
Unknown Working Draft Defines the system messaging interfaces.

浏览器兼容性

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support 未实现 未实现 未实现 未实现 未实现
Feature Android Firefox OS Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support 未实现 1.0 未实现 未实现 未实现 未实现

参见

文档标签和贡献者

 此页面的贡献者: teoli, lil9lll, ananony
 最后编辑者: teoli,