How to access local data from an external web page?

I am trying to access data inside assets / css from an external HTML file.

The process is as follows:

<html> 
<head>
<meta name="viewport" content="target-densitydpi=device-dpi, width=device-width, height=device-height, user-scalable=yes" />  
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 
<title>ola</title> 

 <link rel="stylesheet" type="text/css" href="file:///android_asset/css/main.css" />
 <link rel="stylesheet" type="text/css" href="file:///android_asset/css/sch.css" />
 <script type="text/javascript" src="file:///android_asset/css/ethan.js" /> 
 <script type="text/javascript" src="scripts/allinone.js" /> 

</head> 
<body> 
  <input id="btnTest1" name="button" type="button" style="height:0px;width:0px;" /> 
</body> 
</html> 

So, here’s what, I am actually invoking the HTML file using the link (since the HTML file is not present locally). But main.css, sch.cssand ethan.jslocally present in the assets / css folder.

What I'm trying to do is load allinone.js, which is obviously external, and the other three are internal and run the script.

I found a " file:///android_asset/css/main.css", but it does not seem to work.

Please, help....

+3
source share
1 answer

I would be interested to know more about this case. My understanding is this:

  • HTML , , Android- Android
  • /, HTML (-, , ).

- , , ://URI , - , , API webView:

  • HTML , , webView. HTML JS/CSS.
  • "loadUrl" WebView CSS/Javascript ( , # 1 ). :

mWebView.loadUrl("javascript:injectJavascript(js)");

"js" - Javascript, Android-, injectJavascript - HTML , DOM. CSS...

, . WebView, "addCssToDom" - , , , .

0

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


All Articles