Reputation: 303
I have strange problem on Chrome for Android with local website.
It works perfect on Firefox for Andorid, but not for Chrome.
On my site here: https://passcombo.com there is download link with a zip file.
What I do is:
Looks like there is path problem with relative paths?
But firefox works!
Working alternative is Firefox, but there you need to write correct strange path: "file:///storage/emulated/0/..../...html" But... Currently Chrome is mostly used on Andorid so it's bad local sites not working :/
Upvotes: 12
Views: 28926
Reputation: 854
I'm using Chrome under Android 10 on my admittedly budget tablet, but EVERY attempt to persuade Chrome to access CSS and JavaScript files fails on my tablet.
I've tried using a base href tag to specify a root directory to search - works on Windows/Linux desktop/laptop systems, fails on my Android Tablet.
I've tried specifying absolute paths of the sort "file:///sdcard/projects/test1/" in both the css link tag and the script tags for the JavaScript files - works on desktop/laptop, fails on my tablet.
Chrome appears to refuse categorically to load ANY additional resources regardless of what measures you take, if you try loading them from a local directory.
Apparently the only solution now is to install a web server on your Android device, spend however many hours or days it takes to configure it, then access your files using localhost, and at the moment, I'm not even sure that hassle will succeed. Chrome on Android appears to be operating in fascist lockdown mode with respect to ANY home written code that isn't accessed via a recognised web server.
Personally, I think it will be far less troublesome to install Firefox and perform my tablet testing using that, and tell Chrome where to get off. Which is a pity, because on desktop and laptop systems, Chrome's debugging dovetails beautifully with my workflow and operates at speed. Will report on whether or not using Firefox instead is successful in due course ...
... and that has now failed as well. Android 10 won't allow me to open ANYTHING in Firefox from my file explorer. Frustration level: Spinal Tap 11.
Also tried the above suggestion of storing the resource files in:
file:///sdcard/Android/data/com.android.chrome/files/Download/
This has failed as well.
The short version of the above: on my tablet at least, Android is locked down to the extent that it is IMPOSSIBLE to test home written web code that uses CSS and JavaScript files, unless a web server is installed (and I'm willing to bet even that will fail as well after I've tried - watch this space).
Upvotes: 0
Reputation: 1
Upvotes: -1
Reputation: 443
Currently, I am also facing this problem. Chrome does not link to other files on the device, but you can use js and CSS by, using <script>
and <style>
tags and these will be included in the web page. But, for other files, like image, audio, videos, etc. it can't be done on Android still without any server established by 3rd party apps.
Upvotes: 0
Reputation: 303
The only solution I found is to:
where 'file:///storage/0000-0000/' OR 'file:///storage/emulated/0/' is the main path to local storage, and if you copied your folder somehwre deeper then you need to change the 'myfolder' to /somefolder1/somesubfolder/.../ sth
Shame it's the only way to create a web browser app for adroid.
Upvotes: 5
Reputation: 1488
The only solution worked for me in Android is the HTTP Web Server (I used Simple HTTP Server).
Installing different browsers didn't help:
(Apr-2021) I tried installing various Browsers (Chrome, FireFox, even Opera etc.) in Android but none worked. In all cases, when I navigated to the folder containing HTML/JS files using local file:///
URLs ('file:///sdcard/
' or 'file:///storage/emulated/0/
') browsers only displayed the folders but no files.
When I used the absolute path to the HTML file the browsers used content:///
protocol to
render static HTML content, i.e. it did NOT allow execution of JavaScript code.
Upvotes: 2
Reputation: 41
Seems like the only directory Chrome reads local files from is file:///sdcard/Android/data/com.android.chrome/files/Download/
Upvotes: 2
Reputation: 511
In my Android OS version 7, to open a local html file with css and javascript in Google Chrome browser (ver. 64.0.3282.123) I have to open it through an address bar typing as file://localhost/sdcard/
, then navigating to the file location. In spite of mention sdcard
in the address, it opens an internal storage (and my device has actual removable sdcard as well).
Upvotes: 1
Reputation: 4378
It is possible using a HTTP server app on your phone.
For example the SimpleHttpServer.
Set the "Document Root" in the settings of that app to the folder in which your html files reside. Start the server and you will see a local link.
Click on that link and choose the html file you want to show.
If you declared your assets relatively those assets will loaded, too.
Upvotes: 3
Reputation: 506
It doesn't work opening with file explorer, you have to write the path in the address bar file:///sdcard/Download...
or wherever.
JS
works with Chrome
on local html
file in my Galaxy S6
.
Upvotes: 10