search

Home  >  Q&A  >  body text

Android webview interacts with remote page?

Loading a page returned by a remote server in webview in android, can the js in this page interact with android local code?

我想大声告诉你我想大声告诉你2773 days ago806

reply all(4)I'll reply

  • 淡淡烟草味

    淡淡烟草味2017-05-18 10:53:34

    android: This is achieved by directly injecting native js code into the webview page and using the addJavascriptInterface method.
    ios: ios UIWebView itself has the stringByEvaluatingJavaScriptFromString method implementation, which returns the execution result of the js script

    reply
    0
  • 某草草

    某草草2017-05-18 10:53:34

    XmlHttpRequest

    reply
    0
  • 世界只因有你

    世界只因有你2017-05-18 10:53:34

    The js in the webview page can call each other with Android's local java. The implementation method is slightly different for different Android versions. You can search for the specific topic. There are many examples.

    reply
    0
  • 某草草

    某草草2017-05-18 10:53:34

    It shouldn’t be possible, just imagine, your App打开任意url都可以对其注入JS代码,那还有什么安全可言?
    调用Web支付接口的时候,顺便把Cookie、Session什么的往自己服务器上发一份?
    虽然Chrome插件 can do this[/squinting smile].

    reply
    0
  • Cancelreply