I am trying to use the WebkitLibrariesSet library to create a multi-window browser. The problem I encountered is that after the WebkitWebView click hyper link with target="_blank", WebkitWebView successfully creates a new ChildWindow, but the ChildWindow does not load any URLs and is blank. How to get the URL of the ChildWindow or how to let the ChildWindow load the URL? Can anyone help me? Thank u!
all my code:
Sub Globals
'These global variables will be redeclared each time the activity is created.
Private WebkitWebView1 As WebkitWebView
Dim NewUltimateView As WebkitWebView
Private ASViewPager1 As ASViewPager
Private Label1 As Label
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Main")
WebkitWebView1.Initialize(Me,"WebkitWebView1")
WebkitWebView1.JavaScriptEnabled=True
WebkitWebView1.Settings.AlgorithmicDarkeningAllowed=True
WebkitWebView1.Settings.AllowContentAccess=True
WebkitWebView1.Settings.AllowFileAccess=True
WebkitWebView1.Settings.AllowFileAccessFromFileURLs=True
WebkitWebView1.Settings.SupportMultipleWindows=True
WebkitWebView1.Settings.JavaScriptCanOpenWindowsAutomatically=True
WebkitWebView1.Settings.DomStorageEnabled=True
WebkitWebView1.Settings.DatabaseEnabled=True
WebkitWebView1.Settings.LoadWithOverviewMode=True
WebkitWebView1.Settings.UseWideViewPort=True
WebkitWebView1.Settings.LoadsImagesAutomatically=True
WebkitWebView1.WebView.LoadHtml ($"
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
</head>
<body>
Click any link and wait some seconds
<br><br>
<a href="https://www.apple.com" target="_blank">Link with target="_blank"</a>
<br><br>
<a href="https://www.bing.com">Link without target="_blank"</a>
</body>
"$)
ASViewPager1.AddPage(WebkitWebView1.View,"")
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Private Sub WebkitWebView1_CreateChildWindow (IsDialog As Boolean, IsUserGesture As Boolean) As WebView 'Works from API level 1 and above. SupportMultipleWindows option must be enabled.
Log("Added New Child Window")
ToastMessageShow("Added New Child Window",False)
'Return Null if you do not want to create child window. Page will not be loaded!
NewUltimateView.Initialize(Me,"NewUltimateView")
NewUltimateView.EnableSlowWholeDocumentDraw
NewUltimateView.Settings.ImportSettingsFrom(WebkitWebView1.WebView) 'Import settings from main UltimateWebView without referencing.
NewUltimateView.CookieManager.AcceptCookies=True
NewUltimateView.CookieManager.AcceptFileSchemeCookies=True
NewUltimateView.CookieManager.AcceptThirdPartyCookies=True
NewUltimateView.CookieManager.Flush
Log(NewUltimateView.OriginalUrl)
NewUltimateView.Width=100%x
NewUltimateView.Height=100%y
ASViewPager1.AddPage(NewUltimateView.View,"")
Return NewUltimateView.WebView
End Sub
Private Sub NewUltimateView_OverrideUrl (Url As String) As Boolean 'Works from API level 1 to API level 23.
Log("NewUltimateView_OverrideUrl")
End Sub
Private Sub NewUltimateView_OverrideUrl2 (WebResourceRequest As WebkitWebResourceRequest) As Boolean 'Works from API level 24 and above. WebkitWebResourceRequest library required.
Log("NewUltimateView_OverrideUrl2")
End Sub
Private Sub WebkitWebView1_OverrideUrl (Url As String) As Boolean 'Works from API level 1 to API level 23.
Log("WebkitWebView1_OverrideUrl")
End Sub
Private Sub WebkitWebView1_OverrideUrl2 (WebResourceRequest As WebkitWebResourceRequest) As Boolean 'Works from API level 24 and above. WebkitWebResourceRequest library required.
Log("WebkitWebView1_OverrideUrl2")
End Sub
Private Sub WebkitWebView1_PageFinished (Url As String) 'Works from API level 1 and above.
Log("PageFinished")
End Sub
Sub Activity_KeyPress (KeyCode As Int) As Boolean
If KeyCode = KeyCodes.KEYCODE_BACK Then 'back key pressed
WebkitWebView1.GoBack
Return True 'Return True to consume the event
End If
' Return False
End Sub
Private Sub Button1_Click
ToastMessageShow(WebkitWebView1.WebChromeClient.WebViewsChildrenViews,False)
Label1.Text=WebkitWebView1.WebChromeClient.WebViewsChildrenViews.Size
End Sub