tremara1 Active Member Licensed User Longtime User May 8, 2013 #1 I have been hunting around the forum for an answer as to whether or not you can send a value to a JavaScript function in a web view from b4a. I have not found the answer as yet. I looked at webviewextras, am I on the right track?
I have been hunting around the forum for an answer as to whether or not you can send a value to a JavaScript function in a web view from b4a. I have not found the answer as yet. I looked at webviewextras, am I on the right track?
warwound Expert Licensed User Longtime User May 8, 2013 #2 Your b4a code can execute any javascript in a WebView - so yes you can send data to the webpage javascript. You can execute that javascript by prefixing the javascript statement(s) with the javascript: protocol and then using the WebView LoadUrl method. Say you want to execute the javascript statement: Code: Copy myFunction(1, 20); You can execute that statement using this syntax: Code: Copy MyWebView.LoadUrl("javascript:myFunction(1, 20);") WebViewExtras has a method executeJavascript which you could use instead: Code: Copy MyWebViewExtras.executeJavascript(MyWebView, "myFunction(1, 20);") Both techniques are identical - the executeJavascript method simply takes the javascript statement(s), adds the 'javascript:' protocol and then calls the WebVew LoadUrl method. Martin. Upvote 0
Your b4a code can execute any javascript in a WebView - so yes you can send data to the webpage javascript. You can execute that javascript by prefixing the javascript statement(s) with the javascript: protocol and then using the WebView LoadUrl method. Say you want to execute the javascript statement: Code: Copy myFunction(1, 20); You can execute that statement using this syntax: Code: Copy MyWebView.LoadUrl("javascript:myFunction(1, 20);") WebViewExtras has a method executeJavascript which you could use instead: Code: Copy MyWebViewExtras.executeJavascript(MyWebView, "myFunction(1, 20);") Both techniques are identical - the executeJavascript method simply takes the javascript statement(s), adds the 'javascript:' protocol and then calls the WebVew LoadUrl method. Martin.
tremara1 Active Member Licensed User Longtime User May 8, 2013 #3 that was quick Thanks that should help me no end...... Upvote 0