简体   繁体   中英

What to do when android doesn't detect my .css and .js files when I run index.html?

I wrote a .html file that uses css(style.css) and javascript(app.js). When I transferred the folder containing the index.html,style.css and app.js over to my android internal memory,the browser runs the html file but my .css and .js files are not detected.

            <!DOCTYPE html>
            <meta name="viewport" content="width=device-width, initial-scale=1.0">
            <head>
            <link href="style.css" rel="stylesheet" >
            </head>
            <body>
             ....
            </body>
            <script src="app.js" charset="utf-8"></script>

I have tried using "/style.css" and "./style.css". But none of them are helping in detecting the files.

Inline styles in the index.html file work fine and show up in my browser.

Using Chrome on Android 8.1.0 (MIUI 10.1|Stable)

You can load your files somewhere in your device like this :

  • file:///storage/emulated/0/MyDirectory/index.html
  • file:///storage/emulated/0/MyDirectory/style.css
  • file:///storage/emulated/0/MyDirectory/app.js

And then try to address thoes in src and href .


For testing purposes you can also use applications that let you run local servers on your device, like this one: https://play.google.com/store/apps/details?id=com.esminis.server.apache

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM