[英]Android Webview - detect jquery document ready
I use an Android Webview to convert a website to an android app. 我使用Android Webview将网站转换为Android应用程序。 The website uses many JavaScript files and many of them start at $(document).ready().
该网站使用了许多JavaScript文件,其中许多都是从$(document).ready()开始的。 The website works great, but the app recognizes only the $(document).ready() from the first file.
该网站运行良好,但该应用程序仅识别第一个文件中的$(document).ready()。 "console.log("anything");"
“的console.log(” 东西 “);” placed on second file run only if it is outside of $(document).ready().
放在第二个文件上只有在$(document).ready()之外才能运行。
// Java // Java
private void javaRun(String script)
{
if(android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
myWebView.evaluateJavascript(script, null);
} else {
myWebView.loadUrl(script);
}
}
@Override
public void onPageFinished(final WebView view, String url) {
super.onPageFinished(view, url);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
javaRun("javascript:ready();");
}
}, 200);
}
// Javascript // Javascript
function ready()
{
$('li').click(function(){
$(this).toggleClass('read');
});
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.