P pertov Member Mar 14, 2025 #1 Dear All; B4X: WebViewExtras1.AddJavascriptInterface(jsi,"BB") ... Sub md5(str As String) As String Dim j As JavaObject j.InitializeContext Dim s As String s = j.RunMethod("getMD5",Array(str)) s=s.ToUpperCase Log("return>>>"&s) Return s End Sub Sub lg(s As String) LogColor(s,Colors.Magenta) End Sub JavaScript: function nt(){ BB.CallSub("lg",false,"before md5"); var s; s=BB.CallSub("md5",false,"1"); mss.innerText ="и md5="+ s; BB.CallSub("lg",false,"after md5 =" + s); //alert("1="+s); } i'am run javascipt.nt() function + view log window: I'm waiting for the result in the function as shown in the screenshot, but it's = undefined. What am I doing wrong?
Dear All; B4X: WebViewExtras1.AddJavascriptInterface(jsi,"BB") ... Sub md5(str As String) As String Dim j As JavaObject j.InitializeContext Dim s As String s = j.RunMethod("getMD5",Array(str)) s=s.ToUpperCase Log("return>>>"&s) Return s End Sub Sub lg(s As String) LogColor(s,Colors.Magenta) End Sub JavaScript: function nt(){ BB.CallSub("lg",false,"before md5"); var s; s=BB.CallSub("md5",false,"1"); mss.innerText ="и md5="+ s; BB.CallSub("lg",false,"after md5 =" + s); //alert("1="+s); } i'am run javascipt.nt() function + view log window: I'm waiting for the result in the function as shown in the screenshot, but it's = undefined. What am I doing wrong?
drgottjr Expert Licensed User Longtime User Mar 15, 2025 #3 i answered a similar question almost 3 years ago to the date. you should have searched. download the example in post #4 and compare it with yours. i don't think you set up your code correctly. just pay attention to how the javascript interface is set up in webviewextras2. it's not the same as for webviewetras. just the javascript interface. the rest is not applicable. Upvote 0
i answered a similar question almost 3 years ago to the date. you should have searched. download the example in post #4 and compare it with yours. i don't think you set up your code correctly. just pay attention to how the javascript interface is set up in webviewextras2. it's not the same as for webviewetras. just the javascript interface. the rest is not applicable.
DonManfred Expert Licensed User Longtime User Mar 15, 2025 #4 drgottjr said: download the example in post #4 Click to expand... Post #4 of what thread? Ueful would be if you provide a link ;-) Upvote 0
drgottjr said: download the example in post #4 Click to expand... Post #4 of what thread? Ueful would be if you provide a link ;-)
teddybear Well-Known Member Licensed User Mar 15, 2025 #5 DonManfred said: Post #4 of what thread? Ueful would be if you provide a link ;-) Click to expand... I supplement the link for post#2 Upvote 0
DonManfred said: Post #4 of what thread? Ueful would be if you provide a link ;-) Click to expand... I supplement the link for post#2
drgottjr Expert Licensed User Longtime User Mar 15, 2025 #6 teddybear said: I supplement the link for post#2 Click to expand... thanks to @teddybear. search does work! Upvote 0
teddybear said: I supplement the link for post#2 Click to expand... thanks to @teddybear. search does work!
P pertov Member Mar 17, 2025 #7 drgottjr said: ....... i don't think you set up your code correctly. .... Click to expand... hi, in your example (link), there is no java to javascript value return. calls without returning results from java to jscript =work in any [debug|release] mode release mode= debug mode= sources in #1 post Last edited: Mar 17, 2025 Upvote 0
drgottjr said: ....... i don't think you set up your code correctly. .... Click to expand... hi, in your example (link), there is no java to javascript value return. calls without returning results from java to jscript =work in any [debug|release] mode release mode= debug mode= sources in #1 post
Erel B4X founder Staff member Licensed User Longtime User Mar 17, 2025 #8 Cross platform method to execute JavaScript and get the result: https://www.b4x.com/android/forum/threads/b4x-webview-ckeditor-rich-text-editor.133260/#content Make sure to call it with Wait For. Last edited: Mar 17, 2025 Upvote 0
Cross platform method to execute JavaScript and get the result: https://www.b4x.com/android/forum/threads/b4x-webview-ckeditor-rich-text-editor.133260/#content Make sure to call it with Wait For.
P pertov Member Mar 17, 2025 #9 That's what I experienced: JavaScript: function nt(){ BB.CallSub("lg",false,"before md5"); s=BB.CallSub("md5z",false,s); mss.innerText =">> md5="+ s; BB.CallSub("lg",false,"after md5 =" + s); //alert("1="+s); } in debug mode= >>return value =worked Upvote 0
That's what I experienced: JavaScript: function nt(){ BB.CallSub("lg",false,"before md5"); s=BB.CallSub("md5z",false,s); mss.innerText =">> md5="+ s; BB.CallSub("lg",false,"after md5 =" + s); //alert("1="+s); } in debug mode= >>return value =worked
FrostCodes Active Member Licensed User Longtime User Mar 17, 2025 #10 Maybe check my examples here: WebViewExtras Examples for beginners I noticed a lot of beginners are confused about how to use the WebViewExtras library so I made a detailed example. If you find it useful, kindly consider buying me a coffee. Code works on Android 4.4 to Android 14 (last tested version). It should work for the latest Android versions but I... www.b4x.com Upvote 0
Maybe check my examples here: WebViewExtras Examples for beginners I noticed a lot of beginners are confused about how to use the WebViewExtras library so I made a detailed example. If you find it useful, kindly consider buying me a coffee. Code works on Android 4.4 to Android 14 (last tested version). It should work for the latest Android versions but I... www.b4x.com
P pertov Member Mar 18, 2025 #11 thanks for Our answers, I'm resigned 1.WebViewExtras2.DefaultJavascriptInterface..CallSub(...) in debug mode - Does not return a value result 2.if sub no exists WebViewExtras2.DefaultJavascriptInterface..CallSub(...) = returns a string error message instead of Null or Error Attachments testcall_JS_J_JS.zip testcall_JS_J_JS.zip 9.7 KB · Views: 331 Upvote 0
thanks for Our answers, I'm resigned 1.WebViewExtras2.DefaultJavascriptInterface..CallSub(...) in debug mode - Does not return a value result 2.if sub no exists WebViewExtras2.DefaultJavascriptInterface..CallSub(...) = returns a string error message instead of Null or Error