Android javascript注入,我如何调用这个函数$(document).ready(function(){…

Android javascript injection, how would I call this function $(document).ready(function(){...})

本文关键字:函数 document function ready 调用 注入 javascript 何调用 Android      更新时间:2023-09-26

我正在工作的一些javascript注入到我的android webview。我只是不完全确定它在寻找

的语法

我想在我的html页面调用这个函数:$(document).ready(function({...})

我有一个webview和javascript界面设置在我的应用程序。我也有javascript启用

    myWebView.getSettings().setJavaScriptEnabled(true);
    myWebView.loadUrl("file:///android_asset/mydocument.html");
    myWebView.addJavascriptInterface(new myJavaScriptInterface(), "jsintector");
    myWebView.loadUrl("javascript:ready()");

javascript:ready()应该是android中调用html页面中正确函数的部分。访问这个函数的正确语法是什么?$(document).ready(function({...})

(编辑:javascript已经在html中,我只是想强制它从android端运行)

尝试在…之前搜索

无论如何,最简单的方法是这样做:

  1. load the url into a string
  2. inject the javascript into the string
  3. 使用loaddata将html加载到webview