0
我想使用WebView为Android创建一个Web应用程序。我cenary很简单,我有一个按钮,一个index.html文件:关于Android WebView的JS级别15的JS ReferenceError
<button id="connect-button" onclick="connect">Connect</button>
和简单(脚本)元素:
<script>
connect = function() {
alert("Oi");
};
</script>
在Android方面我有一个在Webview上加载此文件的活动
WebView web;
web = (WebView) findViewById(R.id.webview01);
//ProgressBar related to the xml
progressBar = (ProgressBar) findViewById(R.id.progressBar1);
progressBar.setMax(100);
web.setWebViewClient(new myWebClient());
web.setWebChromeClient(new MyWebViewClient());
web.getSettings().setJavaScriptEnabled(true);
web.getSettings().setLoadWithOverviewMode(true);
web.getSettings().setUseWideViewPort(true);
web.loadUrl("file:///android_asset/index.html");
对于api级别19或以上的一切正常。但对于API 15到18级的webview无法加载我简单的JavaScript方法“连接”。
我搜索了很多关于webview for api level bellow 19的问题,但这是非常简单的测试。有时某人会做出类似于api 15的事情?