[英]Android webview not displaying html with external js links
I have used the following code to display a website that i have included in the assets directory in my android app: 我已使用以下代码显示我包含在我的android应用程序的Assets目录中的网站:
WebView myWebView = (WebView)findViewById(R.id.myWebView);
WebSettings webSettings = myWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
myWebView.loadUrl("file:///android_asset/my_site/index.html");
In the index.html
file i have called some external js files. 在
index.html
文件中,我调用了一些外部js文件。 But the external js files are not being called. 但是没有调用外部js文件。 Why is this happening?
为什么会这样呢? I have loaded the same website locally from iOS, and it is working perfectly.
我已经从iOS本地加载了相同的网站,并且运行良好。 What can I do to rectify this?
我该怎么办才能纠正这个问题?
try this, 尝试这个,
WebSettings settings = webView.getSettings();
settings.setDomStorageEnabled(true);
I was actually doing a HTML5 game using phaser.js
. 我实际上是使用
phaser.js
进行HTML5游戏的。 It seems like the only way out was cocoonjs. 似乎唯一的出路是cocoonjs。 Didn't find any other solution.
找不到其他解决方案。 Why does android's webview doesn't show the game by default without using any wrappers?
为什么默认情况下,如果不使用任何包装程序,Android的Web视图就不会显示游戏? I had the same game working perfect in iOS and windows webview without using any kind of wrappers.
我在不使用任何包装的情况下,在iOS和Windows Webview上都能完美运行同一款游戏。
add Internet permissions in androidManifest.xml page. 在androidManifest.xml页面中添加Internet权限。
<!-- Permission: Allow application to connect to Internet -->
<uses-permission android:name="android.permission.INTERNET" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.