UI Components
WebView
UI component for rendering web content.
<WebView>
is a UI component for rendering web content. The content can be from a remote URL, a local file, or an inline string.
See also: HtmlView.
<WebViewsrc="https://nativescript.org/" />
<WebViewsrc="https://nativescript.org/" />
<webViewsrc="https://nativescript.org/" />
<webviewsrc="https://nativescript.org/" />
<webViewsrc="https://nativescript.org/" />
<WebViewsrc="https://nativescript.org/" />
Tip
To be able to use gestures inside a WebView on Android, disable zoom controls.
Props β
src β
src: string
The source to load in the WebView. The value can be a valid HTTP URL, a path to a local HTML file, or a HTML string.
Example:
webView.src ='https://nativescript.org/'
webView.src ='~/assets/html/index.html'
webView.src ='<div><h1>Some static HTML</h1></div>'
Insecure URLs
Depending on the software version of the device, insecure URLs may be blocked (http://
), it's recommended to always use secure URLs (https://
).
canGoBack β
canGoBack: boolean
Gets a value indicating whether the WebView can navigate back.
canGoForward β
canGoForward: boolean
Gets a value indicating whether the WebView can navigate forward.
disableZoom β
disableZoom: boolean
Disable zooming in the WebView.
iosAllowInlineMediaPlayback β
iosAllowInlineMediaPlayback: boolean
Enables inline media playback on iOS. By default, WebView forces iPhone into fullscreen media playback. iOS only.
...Inherited β
For additional inherited properties not shown, refer to the API Reference
Methods β
stopLoading() β
stopLoading(): void
Stops loading the current content (if any).
goBack() β
goBack(): void
Navigates the WebView back.
goForward() β
goForward(): void
Navigates the WebView forward.
reload() β
reload(): void
Reloads the current url.
Events β
loadStarted β
on('loadStarted', (args:EventData) => {
constwebView= arg.object asWebView
console.log('WebView started loading', args.url)
})
Emitted when the page has started loading in the <WebView>
.
See LoadEventData.
loadFinished β
on('loadFinished', (args:EventData) => {
constwebView= arg.object asWebView
console.log('WebView finished loading', args.url)
})
Emitted when the page has started loading in the <WebView>
.
See LoadEventData.
Native component β
- Android:
android.webkit.WebView
- iOS:
WKWebView
- Previous
- TimePicker