Strange behavior passing a String (java.lang.String) to WebView.loadUrl()

I'm trying to pass a string to a JS function (with no luck) like so:- m_WebView.loadUrl("javascript:myFx('" + myStringArg + "')"); Inside the JS function, i have `console.log("received param = "+ theArg);`
If i pass the java string, i get `Uncaught SysteaxError: Unexpected token ILLEGAL --` from the Troll that is LogCat.
HOWEVER, If i pass a literal e.g `m_WebView.loadUrl("javascript:myFx('QWERTY123')");`, it works fine.

What am i missing?

EDIT#2: FIXED! The downloaded string had a trailing newline character, which when passed to loadUrl messed up the javascript call...An invisible gotcha!
Please post the entire stack trace. What is the value of myStringArg ?

以上就是Strange behavior passing a String (java.lang.String) to WebView.loadUrl()的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准