nsIWebNavigationInfo 编辑

docshell/base/nsIWebNavigationInfo.idlScriptable Exposes a way to get information on the capabilities of Gecko web navigation objects. 1.0 66 Introduced Gecko 1.8 Inherits from: nsISupports Last changed in Gecko 1.8 (Firefox 1.5 / Thunderbird 1.5 / SeaMonkey 1.0)

Implemented by: @mozilla.org/webnavigation-info;1 as a service:

var webNavigationInfo = Components.classes["@mozilla.org/webnavigation-info;1"]
                        .getService(Components.interfaces.nsIWebNavigationInfo);

Method overview

unsigned long isTypeSupported(in ACString aType, in nsIWebNavigation aWebNav);

Constants

Support type constants

ConstantValueDescription
UNSUPPORTED0

Returned by isTypeSupported() to indicate lack of support for a type.

Note: This is guaranteed not to change, so that boolean tests can be done on the return value if isTypeSupported to detect whether a type is supported at all.
IMAGE1Returned by isTypeSupported() to indicate that a type is supported as an image.
PLUGIN2Returned by isTypeSupported() to indicate that a type is supported via an NPAPI ("Netscape 4 API") plug-in. This is not the value returned for "XPCOM plug-ins".
OTHER1 << 15Note: Other return types may be added here in the future as they become relevant. Returned by isTypeSupported() to indicate that a type is supported via some other means.

Methods

isTypeSupported()

Determines whether or not the specified MIME type is supported by the given nsIWebNavigation object. This lets you determine whether a MIME type can be displayed as-is inside a browser, or if the browser will instead forward handling of the data to a plug-in or an external helper application.

Note: This method may cause plug-ins to be rescanned in order to ensure they are properly registered for the types they support.
unsigned long isTypeSupported(
  in ACString aType,
  in nsIWebNavigation aWebNav
);
Parameters
aType
The MIME type to check.
aWebNav
The nsIWebNavigation object on which to check for compatibility. You may specify null to check for compatibility with nsIWebNavigation objects that are in their default state; otherwise, the result is determined based on the configuration of the specified object (that is, how it is configured by using nsIWebBrowserSetup).
Return value

Returns one of the Support type constants, indicating whether or not the specified MIME type is supported, and in what form that support exists.

Example

let webnavigationinfo_service = Components.classes["@mozilla.org/webnavigation-info;1"]
                                .getService(Components.interfaces.nsIWebNavigationInfo);
let support_code = webnavigationinfo_service.isTypeSupported(contentType, null);

if (support_code == webnavigationinfo_service.UNSUPPORTED) {
  dump("Unsupported content-type: not displaying in the browser\n");
}

See also

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

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

发布评论

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

词条统计

浏览:37 次

字数:5925

最后编辑:8年前

编辑次数:0 次

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