nsIContentFrameMessageManager 编辑

IDL file: mozilla-central/source/dom/base/nsIMessageManager.idl

Inherits from: nsISyncMessageSender

This interface provides the environment for scripts that are loaded into content frames using the nsIFrameScriptLoader interface. It enables these scripts to receive messages from the chrome process and send messages back to the chrome process.

Frame scripts can send either synchronous or asynchronous messages to the chrome process: for details on these messaging APIs see the documentation for the nsIContentFrameMessageManager's parent classes nsISyncMessageSender and nsIMessageSender.

Methods

void dump(in DOMString aStr);
DOMString atob(in DOMString aAsciiString);
DOMString btoa(in DOMString aBase64Data);

dump()

Prints the specified string to standard output.

Parameters

NameTypeDescription
aStrStringThe message to log.

atob()

Convert ASCII base64 data to binary data.

Parameters

NameTypeDescription
aAsciiStringStringASCII string to decode.

Returns

String: the decoded binary data.

btoa()

Convert binary data to ASCII base64 data .

Parameters

NameTypeDescription
aBase64DataStringBinary data to encode as base64.

Returns

String: the base64-encoded ASCII string.

Attributes

content

nsIDOMWindow:the current top level window in the frame or null. Read only.

docShell

nsIDocShell:the top level docShell or null. Read only.

Examples

Once you obtain the conten frame messge manager, you can send messages to listeners who registered with Services.mm.addMessageListener

Get content message manager from browser

This could would run in a nsIDOMWindowscope.

var aCFMM = gBrowser.selectedBrowser._docShell.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIContentFrameMessageManager);

Get content message manager from content window

windowhere is a HTML window or any window inside a tab, this code would run from a framescript.

var aCFMM = window.QueryInterface(Ci.nsIInterfaceRequestor)
                              .getInterface(Ci.nsIDocShell)
                              .QueryInterface(Ci.nsIInterfaceRequestor)
                              .getInterface(Ci.nsIContentFrameMessageManager);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:45 次

字数:5428

最后编辑:7 年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文