1. *** New version of B4J is available ***
    B4J v7.8
    Dismiss Notice

Android Question webviewextras pass a string to executejavascript

Discussion in 'Android Questions' started by PassionDEV, Aug 24, 2019.

  1. PassionDEV

    PassionDEV Active Member Licensed User

    i have this sub that executejavascript inside webview

    Dim Javascript As String
    Dim message As String

    message = EditText1.text
    $"addmssage('samer', 'message');"$

    WebViewExtras1.executeJavascript(WebView1, Javascript)

    but it seems i cannot inject the edittext1.text to javascript string how possible i can pass a string inside the javascript variable in this case ?
  2. DonManfred

    DonManfred Expert Licensed User

    You defined a String but you don´t used it. Why?
    You are setting the commands fix in your code
    Edit to add: note that there must be a javascript function named addmssage already in your webpage....
  3. PassionDEV

    PassionDEV Active Member Licensed User

    thanks for replay the addmssage function is already in the js file
    i have tried to pass the message variable like following without success

    Javascript=$"addmssage('samer', ${message});"$
  4. DonManfred

    DonManfred Expert Licensed User

    Javascript=$"addmssage('samer', '${message}');"$
    For any other issue you need to provide more infos. Does not work is the wrong info.. What exactly is the error you get?

    Make sure to enable a logging for any javascripterrors... Don´t know exactly how but i remember that i read something like that in the past.
    Try the forumsearch
    PassionDEV likes this.
  5. PassionDEV

    PassionDEV Active Member Licensed User

    i am so stupid now because i forget to wrap the variable with ' ' which makes the execution read message like a js function thank you for the correction i think i should drink more coffee
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice