WebkitWebView
LayoutChangeProperties
Fields:
- Height As Int
- IsInitialized As Boolean
Tests whether the object has been initialized.
- Left As Int
- Top As Int
- Width As Int
Functions:
- Initialize
Initializes the fields to their default value.
ScrollChangeProperties
Fields:
- IsInitialized As Boolean
Tests whether the object has been initialized.
- X As Int
- Y As Int
Functions:
- Initialize
Initializes the fields to their default value.
WebkitWebView
Events:
- ExecuteJavaScriptResult (Result As String) 'Works from API level 19 and above. JavascriptEnabled must be True.
- OnFocusChange (HasFocus As Boolean) 'Works from API level 1 and above.
- OnKeyEvent (KeyCode As Int, AndroidViewKeyEvent As Object) As Boolean 'Works from API level 1 and above.
- OnLayoutChange (New As LayoutChangeProperties, Old As LayoutChangeProperties) 'Works from API level 11 and above.
- OnScrollChange (New As ScrollChangeProperties, Old As ScrollChangeProperties) 'Works from API level 23 and above.
- OnTouch (AndroidViewMotionEvent As Object) As Boolean 'Works from API level 1 and above.
- OverrideSwipeToReload (UrlToReload As String) As Boolean 'Return False to allow reloading or True to reject. WebkitWebViewClient library required.
- UnhandledKeyEvent (KeyCode As Int, AndroidViewKeyEvent As Object) As Boolean 'Works from API level 28 and above.
Functions:
- AddJavascriptInterface (JavascriptInterface As Object, Name As String) As String
Injects the supplied JavascriptInterface As Object into this WebkitWebView. The object is injected into all frames of the web page, including all the iframes, using the supplied name. This allows the Java object's methods to be accessed from JavaScript.
Added in API level 1.
- BringToFront As String
- CanGoBack As Boolean
Gets whether this WebkitWebView has a back history item.
Added in API level 1.
- CanGoBackOrForward (Steps As Int) As Boolean
Gets whether the page can go back or forward the given number of steps.
Steps as Int (negative - back or positive - forward number of steps to move the history).
Added in API level 1.
- CanGoForward As Boolean
Gets whether this WebkitWebView has a forward history item.
Added in API level 1.
- CaptureScreenshotToBitmap As Bitmap
Capture WebkitWebView visible area to Bitmap.
- CaptureScreenshotToImageFile (FilePath As String, FileNameWithExtension As String, ImageType As String, ImageQuality As Int) As Boolean
Capture WebkitWebView visible area to Image File.
Permission WRITE_EXTERNAL_STORAGE required on API level 29 and above.
ImageType: "jpeg" or "png" or "webp"
ImageQuality: 1 to 100
For API level below 29 you must first request WRITE_EXTERNAL_STORAGE permission.
For API level 29 and above, you must save the file to a Shared Folder (FileProvider).
- ClearCache (IncludeDiskFiles As Boolean) As String
Clears the resource cache. Note that the cache is per-application, so this will clear the cache for all WebkitWebViews used.
IncludeDiskFiles As Boolean (if false, only the RAM cache is cleared)
Added in API level 1.
- ClearFocus As String
Called when this WebkitWebView wants to give up focus.
Added in API level 1.
- ClearFormData As String
Removes the autocomplete popup from the currently focused form field, if present.
Added in API level 1.
- ClearHistory As String
Tells this WebkitWebView to clear its internal back/forward list.
Added in API level 1
- ClearMatches As String
Clears the highlighting surrounding text matches created by findAllAsync(String).
Added in API level 3.
- ClearSslPreferences As String
Clears the SSL preferences table stored in response to proceeding with SSL certificate errors.
Added in API level 1.
- ComputeScroll As String
Called by a parent to request that a child update its values for mScrollX and mScrollY if necessary.
Added in API level 1
- DesignerCreateView (Base As Panel, Lbl As Label, Props As Map) As String
- EnableSlowWholeDocumentDraw As String
For apps targeting the L release, WebkitWebView has a new default behavior that reduces memory footprint and increases performance by intelligently choosing the portion of the HTML document that needs to be drawn. These optimizations are transparent to the developers.
Added in API level 21
- ExecuteJavaScript (JavaScript As String) As String
Execute Javascript in WebkitWebView.
Important: WebkitWebView1.JavaScriptEnabled=True 'Must be set to True somewhere in code
Added in API level 19.
- ExecuteJavaScript2 (JavaScript As String) As String
Execute Javascript in WebkitWebView and got asynchronius backward Result.
Event "ExecuteJavaScriptResult (Result as String)" will be fired when result is available. Result can be "null".
Important: WebkitWebView1.JavaScriptEnabled=True 'Must be set to True somewhere in code
Added in API level 19
Example:
WebkitWebView1.Settings.JavaScriptEnabled=True 'Must be set to True somewhere in code
WebkitWebView1.ExecuteJavascript2([Your JavaScript Code])
Wait For WebkitWebView1_ExecuteJavaScriptResult (Result As String)
'Do your stuff with Result
- FindAllAsync (Find As String) As String
Finds all instances of find on the page and highlights them, asynchronously.
Added in API level 16.
- FindFocus As View
Find the view in the hierarchy rooted at this view that currently has focus.
Added in API level 1.
- FindNext (Forward As Boolean) As String
Highlights and scrolls to the next match found by FindAllAsync(Find As String), wrapping around page boundaries as necessary.
Added in API level 3.
- FlingScroll (X As Int, Y As Int) As String
Added in API level 1.
- GoBack As String
Goes back in the history of this WebkitWebView.
Added in API level 1.
- GoBackOrForward (Steps As Int) As String
Goes to the history item that is the number of steps away from the current item. Steps is negative if backward and positive if forward.
Added in API level 1.
- GoForward As String
Goes forward in the history of this WebkitWebView.
Added in API level 1.
- Initialize (Callback As Object, EventName As String) As String
Method is called automatically when object is added through Designer.
- Invalidate As String
- InvokeZoomPicker As String
Invokes the graphical zoom picker widget for this WebkitWebView.
Added in API level 1.
- IsFocused As Boolean
Returns true if this view has focus.
Added in API level 26.
- LoadData (Data As String, MimeType As String, Encoding As String) As String
Note that JavaScript's same origin policy means that script running in a page loaded using this method will be unable to access content loaded using any scheme other than 'data', including 'http(s)'. To avoid this restriction, use LoadDataWithBaseURL() with an appropriate base URL.
The encoding parameter specifies whether the data Is base64 Or URL encoded. If the data Is base64 encoded, the value of the encoding parameter must be "base64".
Added in API level 1.
- LoadDataWithBaseURL (BaseUrl As String, Data As String, MimeType As String, Encoding As String, HistoryUrl As String) As String
Loads the given data into this WebkitWebView, using baseUrl as the base URL for the content. The base URL is used both to resolve relative URLs and when applying JavaScript's same origin policy. The historyUrl is used for the history entry.
Added in API level 1.
- LoadFileFromDirAssets (FileName As String, IncludeSubFolders As Boolean) As String
Loads file (HTML, TXT, PNG, JPG...) from DirAssets folder into WebkitWebView.
FileName As String - Name of file or file path and name (Example: "test.html" or "TestFolder/test.html").
IncludeSubFolders As Boolean - True for an html file whose objects are in a subfolder or multiple subfolders. False for an html file that has no additional objects in the subfolders but only at the root of the Asset folder. For a non html files value is not important (True or False).
Added in API level 1.
- LoadHTMLString (HTMLString As String) As String
Use this method to load HTML string into WebkitWebView.
Works on API level 1 and above.
- LoadUrl (Url As String) As String
Loads the given URL.
Added in API level 1.
- LoadUrl2 (Url As String, AdditionalHttpHeaders As Map) As String
Loads the given URL with additional HTTP headers, specified as a map from name to value. Note that if this map contains any of the headers that are set by default by this WebkitWebView, such as those controlling caching, accept types or the User-Agent, their values may be overridden by this WebkitWebView's defaults.
Added in API level 8
- PageDown (ToBottom As Boolean) As String
Scrolls the contents of this WebkitWebView down by half the page size.
ToBottom As Boolean (true to jump to bottom of page).
Added in API level 1.
- PageUp (ToTop As Boolean) As String
Scrolls the contents of this WebkitWebView up by half the view size.
ToTop As Boolean (true to jump to the top of the page).
Added in API level 1.
- Pause As String
Does a best-effort attempt to pause any processing that can be paused safely, such as animations and geolocation. Note that this call does not pause JavaScript. To pause JavaScript globally, use pauseTimers().
Added in API level 11
- PauseTimers As String
Pauses all layout, parsing, and JavaScript timers for all WebkitWebViews. This is a global requests, not restricted to just this WebkitWebView. This can be useful if the application has been paused.
Added in API level 1.
- PostUrl (Url As String, PostData As Byte()) As String
Loads the URL with postData using "POST" method into this WebView.
Added in API level 5.
- PrintContent As String
This method is used to print WebkitWebView content.
- Reload As String
Reloads the current URL.
Added in API level 1.
- RemoveJavascriptInterface (Name As String) As String
Removes a previously injected Java object from this WebkitWebView. Note that the removal will not be reflected in JavaScript until the page is next (re)loaded.
Added in API level 11
- RemoveView As String
Use this method to remove this view from parent.
- RequestFocus As Boolean
Call this to try to give focus to WebkitWebView.
Added in API level 1.
- Resume As String
Resumes a WebkitWebView after a previous call to Pause.
Added in API level 11.
- ResumeTimers As String
Resumes all layout, parsing, and JavaScript timers for all WebkitWebViews. This will resume dispatching all timers.
Added in API level 1.
- SaveWebArchive (Filename As String) As String
Saves the current view as a web archive.
Filename As String (the filename where the archive should be placed This value cannot be null).
Added in API level 11
- SendToBack As String
- SetLayout (Left As Int, Top As Int, Width As Int, Height As Int) As String
Changes the WebkitWebView's position and size.
- SetLayoutAnimated (Duration As Int, Left As Int, Top As Int, Width As Int, Height As Int) As String
Changes the WebkitWebView's position and size with animation.
Duration As Int - Duration of the animation in milliseconds
- SetRendererPriorityPolicy (RendererRequestedPriority As Int, WaivedWhenNotVisible As Boolean) As String
Set the renderer priority policy for this WebkitWebView.
Added in API level 26
- SetVisibleAnimated (Duration As Int, Visible As Boolean) As String
- StopLoading As String
Stops the current load.
Added in API level 1.
- SwipeToReloadRefreshAnimation (ShowAnimation As Boolean) As String
This method renders the rotating circle used for SwipeToReload. This method does not initiate a page refresh but only a visual animation.
WebkitWebViewClient required and JavaScriptEnabled must be set to True.
- ZoomBy (ZoomFactor As Float) As String
Performs a zoom operation in this WebkitWebView.
ZoomFactor As Float (the zoom factor to apply. The zoom factor will be clamped to the WebkitWebView's zoom limits. This value must be in the range 0.01 to 100.0 inclusive).
Added in API level 21
- ZoomIn As Boolean
Performs zoom in in this WebkitWebView.
Added in API level 1.
- ZoomOut As Boolean
Performs zoom out in this WebkitWebView.
Added in API level 1.
- IsInitialized As Boolean
Tests whether the object has been initialized.
Properties:
- AccessibilityClassName As String [read only]
Return the class name of this object to be used for accessibility purposes.
Added in API level 23.
- BackgroundColor As Int [write only]
Sets the background color for this view.
Added in API level 1.
- Color As Int [write only]
- Constants As WebkitWebViewConstants [read only]
- ContentHeight As Int [read only]
Gets the height in pixels of the HTML content.
Added in API level 1.
- CookieManager As b4a.android.webkit.webkitcookiemanager [read only]
Gets WebkitCookieManager's properties and methods. WebkitCookieManager library required. Class is auto initialized.
- CopyBackForwardList As b4a.android.webkit.webkitwebbackforwardlist [read only]
Gets the WebBackForwardList for this WebkitWebView. This contains the back/forward list for use in querying each item in the history stack. This is a copy of the private WebBackForwardList so it contains only a snapshot of the current state. Multiple calls to this method may return different objects. The object returned from this method will not be updated to reflect any new state.
Added in API level 1.
- DataDirectorySuffix As String [write only]
Define the directory used to store WebView data for the current process.
Added in API level 28.
- DownloadListener As b4a.android.webkit.webkitdownloadlistener [read only]
Gets WebkitDownloadListener's properties and methods. WebkitDownloadListener library required. Class is auto initialized.
- Enabled As Boolean
- FavIcon As Bitmap [read only]
Gets the favicon for the current page.
Added in API level 1.
- Height As Int
- InitialScale As Int [write only]
Sets the initial scale in percent for this WebkitWebView. 0 means default.
Added in API level 1.
- IsPrivateBrowsingEnabled As Boolean [read only]
Gets whether private browsing is enabled in this WebkitWebView.
Added in API level 11.
- JavaScriptEnabled As Boolean
Tells the WebkitWebView to enable JavaScript execution.
Added in API level 1.
- Left As Int
- MimeTypeMap As b4a.android.webkit.webkitmimetypemap [read only]
Gets WebkitMimeTypeMap's properties and methods. WebkitMimeTypeMap library required. Class is auto initialized.
- NetworkAvailable As Boolean [write only]
Informs WebView of the network state.
Added in API level 3.
- OnCheckIsTextEditor As Boolean [read only]
Check whether the called view is a text editor, in which case it would make sense to automatically display a soft input window for it.
Added in API level 3.
- OriginalUrl As String [read only]
Gets the original URL for the current page.
Added in API level 3.
- OverScrollMode As Int [write only]
Set the over-scroll mode for this view.
Values: OVER_SCROLL_ALWAYS, OVER_SCROLL_IF_CONTENT_SCROLLS (allow over-scrolling only if the view content is larger than the container), or OVER_SCROLL_NEVER. Setting the over-scroll mode of a view will have an effect only if the view is capable of scrolling.
Added in API level 9
- Padding As Int()
- Parent As Object [read only]
- Progress As Int [read only]
Gets the progress for the current page.
Added in API level 1.
- SafeBrowsingPrivacyPolicyUrl As ba.uri.androidneturi [read only]
Returns a URL pointing to the privacy policy for Safe Browsing reporting.
Gets android.net.Uri as AndroidNetUri. Link for AndroidNetUri library and documentations:
https://www.b4x.com/android/forum/threads/androidneturi-library.136402/
Added in API level 27.
- Settings As b4a.android.webkit.webkitwebviewsettings [read only]
Gets WebkitWebViewSettings properties and methods. WebkitWebViewSettings library required. Class is auto initialized.
- SwipeToReload As Boolean
Enable or disable WebkitWebView's Swipe to Reload function.
WebkitWebViewClient required and JavaScriptEnabled must be set to True.
- Tag As Object
- Text As String
- Title As String [read only]
Gets the title for the current page.
Added in API level 1.
- Top As Int
- Url As String [read only]
Gets the URL for the current page.
Added in API level 1.
- URLUtil As b4a.android.webkit.webkiturlutil [read only]
Gets WebkitURLUtil's properties and methods. WebkitURLUtil library required. Class is auto initialized.
- View As View [read only]
Get WebkitWebView as android.view.View.
- Visible As Boolean
- WebChromeClient As b4a.android.webkit.webkitwebchromeclient [read only]
- WebView As WebView [read only]
Gets native B4A WebView which is auto associated with WebkitWebView.
- WebViewClient As b4a.android.webkit.webkitwebviewclient [read only]
- WebViewDatabase As b4a.android.webkit.webkitwebviewdatabase [read only]
Gets WebkitWebViewDatabase's properties and methods. WebkitWebViewDatabase library required. Class is auto initialized.
- Width As Int
WebkitWebViewConstants
Fields:
- OVER_SCROLL_ALWAYS As Int
- OVER_SCROLL_IF_CONTENT_SCROLLS As Int
- OVER_SCROLL_NEVER As Int
- RENDERER_PRIORITY_BOUND As Int
- RENDERER_PRIORITY_IMPORTANT As Int
- RENDERER_PRIORITY_WAIVED As Int
Functions:
- Initialize As String
Initializes the object.
- IsInitialized As Boolean
Tests whether the object has been initialized.