App Inventor 2 CustomWebView 拓展:高级版Web浏览器,完美浏览现代Web前端页面

« 返回首页

CustomWebView 拓展

高级版Web浏览器,完美浏览现代Web前端页面,由中文网更新及维护,基于开源项目开发。

原生 Web浏览器 组件无法正常浏览部分现代Web页面,无法浏览带端口url的页面,这款拓展统统解决。

  • .aix 拓展下载:

cn.fun123.CustomWebView.aix

基础使用方法:

例如,使用此拓展访问 react 写的网页,效果如下:

而使用原生的Web浏览器则无法访问:

属性

AdHosts
Sets the ad hosts which will be blocked
AutoLoadImages
Returnss whether the WebView should load image resources
AutoplayMedia
Returns whether the WebView requires a user gesture to play media
BackgroundColor
Sets background color of webview
BlockAds
Sets whether to block ads or not
BlockNetworkLoads
Returns whether the WebView should not load resources from the network
CacheMode
Gets cache mode of active webview
CurrentPageTitle
Title of the page currently viewed
CurrentUrl
URL of the page currently viewed
Returns whether deep links are enabled or not
DesktopMode
Returns whether to load content in desktop mode
DisplayZoom
Gets whether the WebView should display on-screen zoom controls
EnableJS
Returns whether webview supports JavaScript execution
FileAccess
Returns whether webview can access local files
Sets whether to follow links or not
FontSize
Returns the font size of text
InitialScale
Sets the initial scale for active WebView. 0 means default. If initial scale is greater than 0, WebView starts with this value as initial scale.
LayerType
Gets layer type
LoadWithOverviewMode
Returns whether the WebView loads pages in overview mode
LongClickable
Returns whether text selection and context menu are enabled or not
OverScrollMode
Gets over scroll mode
PromptForPermission
Sets whether webview will prompt for permission and raise ‘OnPermissionRequest’ event or not else assume permission is granted.
RotationAngle
Gets rotation angle
ScrollBar
Whether to display horizonatal and vertical scrollbars or not
ScrollBarStyle
Gets scroll bar style
Scrollable
Property for Scrollable
SupportMultipleWindows
Returns whether the WebView supports multiple windows
UseWideViewPort
Returns whether the WebView should enable support for the ‘viewport’ HTML meta tag or should use a wide viewport.
UserAgent
Sets the WebView’s user-agent string. If the string is null or empty, the system default value will be used.
UsesLocation
Whether or not to give the application permission to use the Javascript geolocation API
VibrationEnabled
Returns whether vibration feedback enabled on long click
Visible
Returns the visibility of current webview
WebViewString
Get webview string
ZoomEnabled
Gets whether the WebView should support zooming using its on-screen zoom controls and gestures
ZoomPercent
Gets the zoom of the page in percent

事件

AfterArchiveSaved(success,filePath)
Event raised after ‘SaveArchive’ method.If ‘success’ is true then returns file path else empty string.
AfterJavaScriptEvaluated(result)
Event raised after evaluating Js and returns result.
CookiesRemoved(successful)
Event raised after ‘ClearCokies’ method with result
FileUploadNeeded(id,mimeType,isCaptureEnabled)
Event raised when file uploading is needed
FindResultReceived(id,activeMatchOrdinal,numberOfMatches,isDoneCounting)
Event raised after ‘Find’ method with int ‘activeMatchOrdinal’,’numberOfMatches’ and ‘isDoneCounting’
GotCertificate(isSecure,issuedBy,issuedTo,validTill)
Event raised after getting SSL certificate of current displayed url/website with boolean ‘isSecure’ and Strings ‘issuedBy’,’issuedTo’ and ‘validTill’.If ‘isSecure’ is false and other values are empty then assume that website is not secure
GotPrintResult(printId,isCompleted,isFailed,isBlocked)
Event raised after getting previus print’s result.
LongClicked(id,item,secondaryUrl,type)
Event raised when something is long clicked in webview with item(image,string,empty,etc) and type(item type like 0,1,8,etc)
OnCloseWindowRequest(id)
Event triggered when a window needs to be closed
OnConsoleMessage(message,lineNumber,sourceID,level)
Event raised after getting console message.
OnDownloadNeeded(id,url,contentDisposition,mimeType,size)
Event raised when downloading is needed.
OnErrorReceived(id,message,errorCode,url)
Event raised when any error is received during loading url and returns message,error code and failing url
OnFormResubmission(id)
Event raised when resubmission of form is needed
OnGeolocationRequested(origin)
Event raised when page asks for location access. Developer must handle/show dialog from him/herself.
OnHideCustomView()
Event raised when current page exits from full screen mode
OnJsAlert(id,url,message)
Event raised when Js have to show an alert to user
OnJsConfirm(id,url,message)
Tells to display a confirm dialog to the user.
OnJsPrompt(id,url,message,defaultValue)
Event raised when JavaScript needs input from user
OnNewWindowRequest(id,isDialog,isPopup)
Event raised when new window is requested by webview with boolean ‘isDialog’ and ‘isPopup’
OnPermissionRequest(permissionsList)
Event raised when a website asks for specific permission(s) in list format.
OnProgressChanged(id,progress)
Event raised when page loading progress has changed.
OnReceivedHttpAuthRequest(id,host,realm)
Notifies that the WebView received an HTTP authentication request.
OnReceivedSslError(errorCode)
Event for OnReceivedSslError
OnScrollChanged(id,scrollX,scrollY,oldScrollX,oldScrollY,canGoLeft,canGoRight)
Event raised when webview gets scrolled
OnShowCustomView()
Event raised when current page enters in full screen mode
PageLoaded(id)
Event raised when page loading has finished.
PageStarted(id,url)
Event indicating that page loading has started in web view.
Swiped(id,direction)
Event raised when webview is swiped
WebViewStringChanged(value)
When the JavaScript calls AppInventor.setWebViewString this event is run.

方法

AllowGeolocationAccess(allow,remember)
Method for AllowGeolocationAccess
CanGoBack()
Gets whether this WebView has a back history item
CanGoBackOrForward(steps)
Gets whether the page can go back or forward the given number of steps.
CanGoForward()
Gets whether this WebView has a forward history item.
CancelPrinting()
Cancels current print job. You can request cancellation of a queued, started, blocked, or failed print job.
ClearCache()
Clears the resource cache.
ClearCookies()
Removes all cookies and raises ‘CookiesRemoved’ event
ClearFormData(id)
Clears the form data of the webview
Added by Xoma
ClearInternalHistory()
Tells this WebView to clear its internal back/forward list.
ClearLocation()
Clear all location preferences.
ClearMatches()
Clears the highlighting surrounding text matches.
ConfirmJs(confirm)
Whether to proceed JavaScript originated request
ContentHeight()
Gets height of HTML content
ContinueJs(input)
Inputs a confirmation response to Js
CreateShortcut(url,iconPath,title)
Creates a shortcut of given website on home screen
CreateWebView(container,id)
Creates the webview in given arrangement with id
CurrentId()
Returns current id
DismissJsAlert()
Dismiss previously requested Js alert
EvaluateJavaScript(script)
Asynchronously evaluates JavaScript in the context of the currently displayed page.
Find(string)
Finds all instances of find on the page and highlights them, asynchronously. Successive calls to this will cancel any pending searches.
FindNext(forward)
Highlights and scrolls to the next match if ‘forward’ is true else scrolls to previous match.
GetCookies(url)
Get cookies for specific url
GetIds()
Returns a list of used ids
GetInternalHistory(id)
Get internal history of given webview.
GetProgress(id)
Gets the progress for the given webview
GetScrollX()
Return the scrolled left position of the webview
GetScrollY()
Return the scrolled top position of the webview
GetSslCertificate()
Gets the SSL certificate for the main top-level page and raises ‘GotCertificate’ event
GetWebView(id)
Returns webview object from id
GoBack()
Goes back in the history of this WebView.
GoBackOrForward(steps)
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.
GoForward()
Goes forward in the history of this WebView.
GoToUrl(url)
Loads the given URL.
GrantPermission(permissions)
Grants given permissions to webview.Use empty list to deny the request.
HideCustomView()
Hides previously shown custom view
InvokeZoomPicker()
Invokes the graphical zoom picker widget for this WebView. This will result in the zoom widget appearing on the screen to control the zoom level of this WebView.Note that it does not checks whether zoom is enabled or not.
LoadHtml(html)
Loads the given data into this WebView using a ‘data’ scheme URL.
LoadInNewWindow(id)
Loads requested url in given webview
LoadWithHeaders(url,headers)
Loads the given URL with the specified additional HTTP headers defined is list of lists.
PageDown(bottom)
Scrolls the contents of the WebView down by half the page size
PageUp(top)
Scrolls the contents of the WebView up by half the page size
PauseWebView(id)
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.
PostData(url,data)
Loads the URL with postData using ‘POST’ method into active WebView.
PrintWebContent(documentName)
Prints the content of webview with given document name
ProceedHttpAuthRequest(username,password)
Instructs the WebView to proceed with the authentication with the given credentials.If both parameters are empty then it will cancel the request.
ProceedSslError(proceed)
Method for ProceedSslError
Registers to open specified link in associated external app(s)
Reload()
Reloads the current URL.
RemoveWebView(id)
Destroys the webview and removes it completely from view system
RestartPrinting()
Restarts current/previous print job. You can request restart of a failed print job.
ResubmitForm(reSubmit)
Whether to resubmit form or not.
ResumeWebView(id)
Resumes the previously paused WebView.
SaveArchive(dir)
Saves the current site as a web archive
ScrollTo(x,y)
Scrolls the webview to given position
SetCookies(url,cookieString)
Sets cookies for given url
SetVisibility(id,visibility)
Sets the visibility of webview by id
SetWebView(id)
Set specific webview to current webview by id
StopLoading()
Stops the current load.
UploadFile(contentUri)
Uploads the given file from content uri.Use empty string to cancel the upload request.
ZoomBy(zoomP)
Performs a zoom operation in the WebView by given zoom percent
ZoomIn()
Performs zoom in in the WebView
ZoomOut()
Performs zoom out in the WebView

BrowserPromptHelper

Component for BrowserPromptHelper

属性

None

事件

OnResume(url)
Event raised when app gets resumed and gives the url which started this activity/screen if there is any else empty string

方法

GetStartUrl()
Returns the url which started the current activity

DownloadHelper

Component for DownloadHelper

属性

NotificationVisibility
Sets download notification visibility

事件

DownloadCompleted()
Event invoked when downloading gets completed
DownloadFailed()
Event invoked when downloading gets failed
DownloadProgressChanged(progress)
Event invoked when downloading progress changes
DownloadStarted(id)
Event invoked when downloading starts
GotFileSize(fileSize)
Event invoked after getting file size

方法

Cancel()
Cancels the current download request
Download(url,mimeType,fileName,downloadDir)
Downloads the given file
GetFileSize(url)
Tries to get file size
GetMimeType(id)
Method for GetMimeType
GetUriString(id)
Method for GetUriString
GuessFileName(url,mimeType,contentDisposition)
Returns guessed file name
文档反馈