Webview does not load javascript or CSS

Hi everyone, this is my first Android app.

I upload to my website on the local network, I serve the IIS server in my home. (192.xxx). The page loads just fine if I use my computer and goto http://192.xxx/index.html

However, when I put the same path in my webview, I see the webpage, but it doesn't seem to load javascript or css?

<script type="text/javascript" src="js/jqueryv1.9.1.js" ></script> <script type="text/javascript" src="js/jMobile.js" ></script> <script type="text/javascript" src="js/jQueryRotate.js"></script> <script type="text/javascript" src="js/main.js"></script> <link href='css/jqueryMobile.css' rel='stylesheet' type='text/css'> 

My webview code:

 package com.example.mainactivity; import android.app.Activity; import android.content.pm.ActivityInfo; import android.os.Bundle; import android.view.KeyEvent; import android.view.Window; import android.view.WindowManager; import android.webkit.WebView; import android.webkit.WebViewClient; public class MainActivity extends Activity { private WebView mWebView; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().requestFeature(Window.FEATURE_NO_TITLE); mWebView = new WebView(this); mWebView.loadUrl("http://192.xxx.x.xx/index.html"); mWebView.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; } }); this.requestWindowFeature(Window.FEATURE_NO_TITLE); this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); //setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR); this.setContentView(mWebView); } @Override public boolean onKeyDown(final int keyCode, final KeyEvent event) { if ((keyCode == KeyEvent.KEYCODE_BACK) && mWebView.canGoBack()) { mWebView.goBack(); return true; } return super.onKeyDown(keyCode, event); } } 

What can I lose to make this happen?

Update

enter image description here

update 2

enter image description here

update 3

enter image description here

0
source share
2 answers

Was the css style loaded and efficient?

0
source

You must enable javascript in your webview to load javascript

 mWebView = new WebView(this); WebSettings webSettings = mWebView.getSettings(); webSettings.setJavaScriptEnabled(true); 
0
source

Source: https://habr.com/ru/post/949226/


All Articles