XUL:browser
From MDC
« XUL Reference home [ Examples | Attributes | Properties | Methods | Related ]
A frame which is expected to contain a view of a Web document. It is similar to an iframe except that it holds a page history and contains additional methods to manipulate the currently displayed page.
Most of the properties and methods of the browser will rarely be used and can only be called from chrome URLs. Other URLs will need to use the document and history objects to change the displayed document.
- Attributes
- autocompleteenabled, autocompletepopup, autoscroll, disablehistory, disablesecurity, homepage, showcaret, src, type
- Properties
- accessibleType, canGoBack, canGoForward, contentDocument, contentPrincipal, contentTitle, contentViewerEdit, contentViewerFile, contentWindow, currentURI, docShell, documentCharsetInfo, homePage, markupDocumentViewer, preferences, securityUI, sessionHistory, webBrowserFind, webNavigation, webProgress
- Methods
- addProgressListener, goBack, goForward, goHome, gotoIndex, loadURI, loadURIWithFlags, reload, reloadWithFlags, removeProgressListener, stop
[edit] Examples
<!-- shows Mozilla homepage inside a groupbox --> <groupbox flex="1"> <caption label="Mozilla homepage"/> <browser type="content" src="http://www.mozilla.org" flex="1"/> </groupbox>
[edit] Attributes
|
Inherited from XUL element |
- autocompleteenabled
- Type: boolean
- Set to
trueto enable autocomplete of fields.
- autocompletepopup
- Type: id of popup element
- The id of a popup element used to hold autocomplete results for the element.
- autoscroll
- Type: boolean
- Set to
falseto disable autoscroll for this browser. If this attribute is set totrueor omitted, autoscroll will be enabled or depending on the user preferencegeneral.autoScroll.
- disablehistory
- Type: boolean
- If
false, an arrow button will appear on the end of the textbox which will open a dropdown menu of all available results. The default value istrue, hiding the dropdown button.
- disablesecurity
- Type: boolean
- Set this attribute to
trueto disable the security UI for this browser. Omit this attribute off to enable it.
- homepage
- Type: homepage URL
- This attribute allows you to set a homepage for the browser element. It does not have any correlation with the user's browser homepage; instead it is a convenient property to hold a home page. You can switch to this home page using the goHome method.
- showcaret
- Type: boolean
- Whether or not to cause a typing caret to be visible in the content area. Default is
false.
- src
- Type: URL
- The URL of the content to appear in the element.
- type
- Type: one of the values below
- The type of browser, which can be used to set the access of the document loaded inside the browser. If this is not set, the loaded document has the same access as the window containing the
browser.
-
content: A browser for content. The content that is loaded inside the browser is not allowed to access the chrome above it. -
content-primary: The primary browser for content. The content that is loaded inside the browser is not allowed to access the chrome above it. For instance, in a web browser, this would be the element that displays the web page. The window for the primary content can be retrieved more conveniently using window.content.
[edit] Properties
|
Inherited from XUL element Inherited from DOM element |
- accessibleType
- Type: integer
- A value indicating the type of accessibility object for the element.
- canGoBack
- Type: boolean
- This read-only property is
trueif there is a page to go back to in the session history and the Back button should be enabled.
- canGoForward
- Type: boolean
- This read-only property is
trueif there is a page to go forward to in the session history and the Forward button should be enabled.
- contentDocument
- Type: document
- This read-only property contains the document object in the element.
- contentPrincipal
- Type: nsIPrincipal
- This read-only property contains the principal for the content loaded in the browser, which provides security context information.
- contentTitle
- Type: string
- This read-only property contains the title of the document object in the browser.
- contentViewerEdit
- Type: nsIContentViewerEdit
- This read-only property contains the nsIContentViewerEdit which handles clipboard operations on the document.
- contentViewerFile
- Type: nsIContentViewerFile
- Reference to the nsIContentViewerFile interface for the document.
- contentWindow
- Type: window
- This read-only property contains the window object in the element.
- currentURI
- Type: nsIURI
- This read-only property contains the currently loaded URL. To change the URL, use the loadURI method.
- docShell
- Type: nsIDocShell
- This read-only property contains the nsIDocShell object for the document.
- documentCharsetInfo
- Type: nsIDocumentCharsetInfo
- This read-only property contains the nsIDocumentCharsetInfo object for the document which is used to handle which character set should be used to display the document.
- homePage
- Type: string home page URL
- This property holds the value of the user's home page setting.
- markupDocumentViewer
- Type: nsIMarkupDocumentViewer
- This read-only property contains the nsIMarkupDocumentViewer which is responsible for drawing the document.
- preferences
- Type: nsIPrefService
- This read-only property contains an nsIPref object for getting and setting user preferences.
- securityUI
- Type: nsISecureBrowserUI
- The read-only property holds an object which may be used to determine the security level of the loaded document.
- sessionHistory
- Type: nsISHistory
- This read-only property contains the nsISHistory object which holds the session history.
- webBrowserFind
- Type: nsIWebBrowserFind
- This read-only property contains an nsIWebBrowserFind object which can be used to search for text in the document.
- webNavigation
- Type: nsIWebNavigation
- This read-only property contains the nsIWebNavigation object for the document. Most of its methods are callable directly on the element itself, such as goBack and goForward. It also contains the load constants used by reloadWithFlags and loadURIWithFlags.
- webProgress
- Type: nsIWebProgress
- This read-only property contains an nsIWebProgress object which is used to monitor the progress of a document loading.
[edit] Methods
|
Inherited from XUL element Inherited from DOM element |
- addProgressListener( listener )
- Return type: no return value
- Add a progress listener to the browser which will monitor loaded documents. The progress listener should implement the nsIWebProgressListener interface.
- goBack()
- Return type: no return value
- Go back one page in the history.
- goForward()
- Return type: no return value
- Go forward one page in the history.
- goHome()
- Return type: no return value
- Load the user's home page into the browser.
- gotoIndex( index )
- Return type: no return value
- Navigate to the page in the history with the given index. Use a positive number to go forward and a negative number to go back.
- loadURI( uri, referrer, charset )
- Return type: no return value
- Load a URL into the document, with the given referrer and character set.
- loadURIWithFlags( uri, flags, referrer, charset, postData )
- Return type: no return value
- Load a URL into the document, with the specified load flags, the given referrer, character set, and POST data. In addition to the flags allowed for the reloadWithFlags method, the following flags are also valid:
-
LOAD_FLAGS_IS_REFRESH: This flag is used when the URL is loaded because of a meta tag refresh or redirect. -
LOAD_FLAGS_IS_LINK: This flag is used when the URL is loaded because a user clicked on a link. The HTTP Referer header is set accordingly. -
LOAD_FLAGS_BYPASS_HISTORY: Do not add the URL to the session history. -
LOAD_FLAGS_REPLACE_HISTORY: Replace the current URL in the session history with a new one. This flag might be used for a redirect.
(See nsIWebNavigation.loadURI() for details on the referrer and postData parameters.)
- reload()
- Return type: no return value
- Reloads the document in the browser.
- reloadWithFlags( flags )
- Return type: no return value
- Reloads the document in the browser with the given load flags. The flags listed below may be used, which are all constants of the webNavigation property (or the nsIWebNavigation interface). You may combine flags using a or symbol (
|).
-
LOAD_FLAGS_NONE: No special flags. The document is loaded normally. -
LOAD_FLAGS_BYPASS_CACHE: Reload the page, ignoring if it is already in the cache. This is the flag used when the reload button is pressed while the Shift key is held down. -
LOAD_FLAGS_BYPASS_PROXY: Reload the page, ignoring the proxy server. -
LOAD_FLAGS_CHARSET_CHANGE: This flag is used if the document needs to be reloaded because the character set changed.
- removeProgressListener( listener )
- Return type: no return value
- Remove a progress listener from the browser.
- stop()
- Return type: no return value
- Equivalent to pressing the Stop button, this method stops the currently loading document.
[edit] Related
- Interfaces
- nsIAccessibleProvider
