nsIWebNavigation 编辑

docshell/base/nsIWebNavigation.idlScriptable Defines an interface for navigating the web. It provides methods and attributes to direct an object to navigate to a new location, stop or restart an in process load, or determine where the object has previously gone. Inherits from: nsISupports Last changed in Gecko 1.9 (Firefox 3)

This interface is implemented by the following components:

 * @mozilla.org/browser/shistory-internal;1
 * @mozilla.org/browser/shistory;1
 * @mozilla.org/embedding/browser/nsWebBrowser;1
 * @mozilla.org/docshell;1
Gecko 1.9.2 note In Gecko 1.9.2 (Firefox 3.6), the @mozilla.org/webshell;1 component no longer exists; you need to use @mozilla.org/docshell;1 instead.

Method overview

void goBack
void goForward
void gotoIndex( in long index )
void loadURI(in wstring URI , in unsigned long loadFlags , in nsIURI referrer , in nsIInputStream postData, in nsIInputStream headers)
void reload(in unsigned long reloadFlags)
void stop(in unsigned long stopFlags)

Constants

Load Flags

ConstantValueDescription
LOAD_FLAGS_MASK65535This flag defines the range of bits that may be specified.
LOAD_FLAGS_NONE0This is the default value for the load flags parameter.
LOAD_FLAGS_IS_REFRESH16This flag specifies that the load should have the semantics of an HTML Meta-refresh tag (That is, that the cache should be bypassed). This flag is only applicable to loadURI. XXX the meaning of this flag is poorly defined. XXX no one uses this, so we should probably deprecate and remove it.
LOAD_FLAGS_IS_LINK32This flag specifies that the load should have the semantics of a link click. This flag is only applicable to loadURI. XXX the meaning of this flag is poorly defined.
LOAD_FLAGS_BYPASS_HISTORY64This flag specifies that history should not be updated. This flag is only applicable to loadURI.
LOAD_FLAGS_REPLACE_HISTORY128This flag specifies that any existing history entry should be replaced. This flag is only applicable to loadURI.
LOAD_FLAGS_BYPASS_CACHE256This flag specifies that the local web cache should be bypassed, but an intermediate proxy cache could still be used to satisfy the load.
LOAD_FLAGS_BYPASS_PROXY512This flag specifies that any intermediate proxy caches should be bypassed (That is, that the content should be loaded from the origin server).
LOAD_FLAGS_CHARSET_CHANGE1024This flag specifies that a reload was triggered as a result of detecting an incorrect character encoding while parsing a previously loaded document.
LOAD_FLAGS_STOP_CONTENT2048

If this flag is set, Stop() will be called before the load starts and will stop both content and network activity (the default is to only stop network activity).

Effectively, this passes the STOP_CONTENT flag to Stop(), in addition to the STOP_NETWORK flag.
LOAD_FLAGS_FROM_EXTERNAL4096A hint this load was prompted by an external program: take care!
LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP8192This flag specifies that the URI may be submitted to a third-party server for correction. This should only be applied to non-sensitive URIs entered by users.
LOAD_FLAGS_FIRST_LOAD16384This flag specifies that this is the first load in this object. Set with care, since setting incorrectly can cause us to assume that nothing was actually loaded in this object if the load ends up being handled by an external application.
LOAD_FLAGS_ALLOW_POPUPS32768This flag specifies that the load should not be subject to popup blocking checks.

Note

For valid load flag combinations look here nsDocShellLoadTypes.h

Stop Flags

ConstantValueDescription
STOP_NETWORK1This flag specifies that all network activity should be stopped. This includes both active network loads and pending META-refreshes.
STOP_CONTENT2This flag specifies that all content activity should be stopped. This includes animated images, plugins and pending Javascript timeouts.
STOP_ALL3This flag specifies that all activity should be stopped.

Attributes

AttributeTypeDescription
canGoBackPRBoolIndicates if the object can go back. If true this indicates that there is back session history available for navigation. Read only.
canGoForwardPRBoolIndicates if the object can go forward. If true this indicates that there is forward session history available for navigation. Read only.
currentURInsIURIThe currently loaded URI or null. Read only.
documentnsIDOMDocumentRetrieves the current DOM document for the frame, or lazily creates a blank document if there is none. This attribute never returns null except for unexpected error situations. Read only.
referringURInsIURIThe referring URI for the currently loaded URI or null. Read only.
sessionHistorynsISHistoryThe session history object used by this web navigation instance.

Methods

goBack()

Tells the object to navigate to the previous session history item. When a page is loaded from session history, all content is loaded from the cache (if available) and page state (such as form values and scroll position) is restored.

void goBack( );

goForward()

Tells the object to navigate to the next session history item. When a page is loaded from session history, all content is loaded from the cache (if available) and page state (such as form values and scroll position) is restored.

void goForward( );

gotoIndex()

Tells the object to navigate to the session history item at a given index.

void gotoIndex(
  in long index
);
Parameters
index
The index of the session history item to go to.

loadURI()

Loads a given URI. This will give priority to loading the requested URI in the object implementing this interface. If it can't be loaded here however, the URI dispatcher will go through its normal process of content loading.

void loadURI(
  wstring URI,
  unsigned long loadFlags,
  nsIURI referrer,
  nsIInputStream postData,
  nsIInputStream headers
);
Parameters
URI
The URI string to load. For HTTP and FTP URLs and possibly others, characters above U+007F will be converted to UTF-8 and then URL- escaped per the rules of RFC 2396.
loadFlags
Flags modifying load behaviour. This parameter is a bitwise combination of the load flags defined above. (Undefined bits are reserved for future use.) Generally you will pass LOAD_FLAGS_NONE for this parameter.
referrer
The referring URI. If this argument is null, then the referring URI will be inferred internally.
postData
If the URI corresponds to a HTTP request, then this stream is appended directly to the HTTP request headers. It may be prefixed with additional HTTP headers. This stream must contain a \r\n sequence separating any HTTP headers from the HTTP request body. This parameter may be null.
headers
If the URI corresponds to a HTTP request, then any HTTP headers contained in this stream are set on the HTTP request. The HTTP header stream is formatted as: ( HEADER \r\n )* This parameter may be null.

reload()

Tells the Object to reload the current page. There may be cases where the user will be asked to confirm the reload (for example, when it is determined that the request is non-idempotent).

void reload(
  unsigned long reloadFlags
);
Parameters
reloadFlags
Flags modifying load behaviour. This parameter is a bitwise combination of the load flags defined above. (Undefined bits are reserved for future use.) Generally you will pass LOAD_FLAGS_NONE for this parameter.

stop()

Stops a load of a URI.

void stop(
  unsigned long stopFlags
);
Parameters
stopFlags
This parameter is one of the stop flags defined above.

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

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

发布评论

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

词条统计

浏览:110 次

字数:13279

最后编辑:6 年前

编辑次数:0 次

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