Can I inject Javascript code into Chrome Custom Tabs

后端 未结 4 913
既然无缘
既然无缘 2021-01-07 19:05

In my app, I am currently using a web view to display some content. Then, I use Javascript injection to quickly fill out the form for the user.

The only issue is, W

4条回答
  •  梦谈多话
    2021-01-07 19:49

    you need to do it like that by using data:text/html, as prefix for your script

    Try that in your browser tab

    data:text/html,
    

    it will fire the javascript and alert , and as well you can print some in html from url

    so i guess you need just to open the tab with the script

     String suffix = "data:text/html,"
     String script = ""
     String url = suffix + script
     myWebView.loadUrl(url);
    

    It's browser behaviour in desktop and mobile

    I haven't try it in WebView.loadUrl and actually still if it's done by WebView.loadUrl it will be a security hole

提交回复
热议问题