Something like:
WebViewExtras1.executeJavascript(browser, Javascript)
WebViewExtras1.executeJavascript(browser, Javascript)
Sub Process_Globals
'These global variables will be declared once when the application starts.
'Public variables can be accessed from all modules.
Public App As Application
Public NavControl As NavigationController
Private Page1 As Page
Private toolbar1 As Page
Private WebView1 As WebView
End Sub
Private Sub Application_Start (Nav As NavigationController)
NavControl = Nav
Page1.Initialize("Page1")
Page1.Title = "Page 1"
Page1.RootPanel.LoadLayout("provawebview")
NavControl.ShowPage(Page1)
NavControl.ToolBarVisible=True
Dim htmlpage As String
htmlpage="<!DOCTYPE html>"
htmlpage=htmlpage&"<html>"
htmlpage=htmlpage&"<body>"
htmlpage=htmlpage&"<script>function myFunction() {document.getElementById('demo').innerHTML = 'Paragraph changed';}</script>"
htmlpage=htmlpage&"<h1>My First Web Page</h1>"
htmlpage=htmlpage&"<p id='demo'>A Paragraph.</p>"
htmlpage=htmlpage&"<Button Type='Button' onclick='myFunction()'>Try it</Button>"
htmlpage=htmlpage&"</body>"
htmlpage=htmlpage&"</html>"
Log (htmlpage)
WebView1.LoadHtml(htmlpage)
End Sub
Sub WebView1_PageFinished (Success As Boolean, Url As String)
Log ("Page Loaded")
Dim ww As NativeObject=Webview1
Dim scripttext As String
scripttext="myfunction();"
Log (scripttext)
ww.RunMethod("stringByEvaluatingJavaScriptFromString:",Array(scripttext))
End Sub
Dim Javascript As String
Javascript="B4A.CallSub('ProcessHTML', true, tit('title') )"
Log("PageFinished: "&Javascript)
WebViewExtras1.executeJavascript(browser, Javascript)
No.
Do you want to get the html?
Try:
B4X:Dim html As String = ww.RunMethod("stringByEvaluatingJavaScriptFromString:",Array("document.documentElement.innerHTML"))
function tit( classe_titoli ){
var elements = document.getElementsByClassName( classe_titoli );
var t="";
for(var i = 0, length = elements.length; i < length; i++) {
t = t + elements[i].innerText + "|";
}
return t;
}
Tryhow can i get the text as a string from the webview after page finished loading??
is there something like Webview1.DocumentText?
*** WebKit discarded an uncaught exception in the webView:decidePolicyForNavigationAction:request:frame:decisionListener: delegate: <NSInvalidArgumentException> *** -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[0]