Sailfish Webview
API DocumentationWebView QML Type
A component for adding web content to a page. More...
Import Statement: | import . |
Properties
- active : bool
- canGoBack : bool
- canGoForward : bool
- httpUserAgent : string
- loadProgress : int
- loaded : bool
- loading : bool
- popupProvider : PopupProvider
- privateMode : bool
- security : QMozSecurity
- title : QString
- url : QUrl
- webViewPage : WebViewPage
Signals
- contentOrientationChanged(Qt::ScreenOrientation orientation)
- linkClicked(string url)
- loadRedirect()
- viewDestroyed()
Methods
- clearSelection()
- goBack()
- goForward()
- load(string url)
- loadHtml(string html, url baseUrl)
- loadText(string text, string mimeType)
- reload()
- runJavaScript(string script, variant callback, variant errorCallback)
- stop()
Detailed Description
The WebView
component allows you to add web content to a QML page.
The WebView
QML type is exposed through the Sailfish.WebView
QML import namespace.
Exaple of use:
import QtQuick 2.0 import Sailfish.Silica 1.0 import Sailfish.WebView 1.0 ApplicationWindow { id: root initialPage: Component { WebViewPage { WebView { anchors.fill: parent url: "http://www.sailfishos.org" } } } }
Advanced users may wish to make use of the additional attributes or the experimental attributes.
See also WebViewPage.
Property Documentation
This property is true
when WebView is actively evaluating or rendering content.
If a webview is not set as active, it will not display any content.
The active property follows application visibility and status of the WebViewPage unless explicitly set. When the application or WebView is hidden (not visible) for the end user, active should be false.
Touching the content forces WebView to active state.
Normally application developers do not need to alter the default behavior.
Whether the "forward" navigation action is available.
If the user has navigated back (via goBack()) without later loading a new page by clicking a link or setting the url property, then forward navigation will be available.
See also goForward().
The user agent string to be used for http/https requests.
Set this value to override the user agent string that will be used for http and https requests. This will be sent in the "User-Agent"
header field.
Setting this value overrides all other user agent configurations.
If the string is left empty or cleared, it will get set to the actual user agent string used at the start of each request. If there are domain overrides configured the value may be dependent on the domain being accessed and so may change again on future requests.
Changing the value mid-request will not alter the behaviour for the onging request, but will affect any future requests.
Defaults to an empty string.
The load progress (percentage) of the current page.
When the webview begins loading a new page, this value will be set to 1 (percent) and then updated as more content is loaded. When loading is complete, this value will be set to 100 (percent).
Whether the webview content has finished loading successfully.
See also load().
Whether the webview is currently loading page content.
See also loadProgress and loaded.
A provider of custom user interaction components
Client applications can define their own custom user interaction components which extend the various interface types defined in the Sailfish.WebView.Popups namespace.
In order for those custom components to be used by the WebView, the client must register a PopupProvider instance (which specifies the various custom components which should be used) with the WebView via this property.
It is an optional property.
See also Popup Customization, PopupProvider, and custompopups.
Whether the webview is in private browsing mode.
If private mode is enabled, history will not be stored in the device.
Note: the value for this property must be set when the webview is initialized. Any attempt to set the value of this property after the webview has been instantiated will have no effect.
Provides the TLS state and security capabilities of the connection with the site.
The QMozSecurity type is available in the Qt5Mozilla import namespace.
The URL being loaded and displayed by the webview.
Clients can set this property to navigate to a new location. If the webview is redirected, the value of this property will automatically be updated.
See also load().
The WebViewPage the WebView is embedded in.
Signal Documentation
This signal is emitted when the screen orientation of the rendered content changes.
This signal is emitted when the user selects a link on the page.
When emitted url will be set to href selected.
Emitted if load() resulted in a redirect.
Method Documentation
Navigate back to the previous location in history.
See also canGoBack and goForward().
Navigate forward to the next location in history.
See also canGoForward and goBack().
loadHtml(string html, url baseUrl) |
Loads the specified html content, performing symbol resolution from the given baseUrl.
Loads the specified text content, displaying appropriately for the specified mimeType.
Runs JavaScript snippet in the context of the loaded DOM document.
When the script returns, callback with a single argument that is the return value is called. The callback argument is optional, if set to undefined
(the default), the return value will be discarded.
If the function fails errorCallback is called with a single argument containing the error string. The errorCallback argument is optional, if set to undefined
(the default), any errors are silently ignored.
runJavaScript("return document.title", function(result) { console.log("Document title is", result); });
Note: The script must have explicit return statement.
Note: Only basic data types are supported as script return values and async function or Promise are not supported for the script.