How to set relative path to current folder?
Just dot is working. The doctype makes a difference however as sometimes the ./ is fine as well.
<a href=".">Link to this folder</a>
Relative paths in HTML from `filesDir` won't work
I believe you need to call setAllowFileAccess
in WebSettings
to enable access to file://
URLs, as they're disabled by default in API 30 and above.
webview.getSettings().setAllowFileAccess(true);
html linking , relative path
Your code is valid, but you might be mistaken in the location of the files your linking to. That would result in an invalid url.
Have a look at a folder structure as below. You've got a project folder name project-example
this folder contains the index.html
and the folders templates
and images
.
If you want to link in your index.html
to the files in those folders the src or href would have to be something like templates/style.css
or images/image.png
.
Related Topics
Responsively Change Div Size Keeping Aspect Ratio
Why Does Styling the Background of the Body Element Affect the Entire Screen
How to Change Bootstrap 3 Column Order on Mobile Layout
Set Textview Text from Html-Formatted String Resource in Xml
Manually Triggering Form Validation Using Jquery
Clear All Fields in a Form Upon Going Back With Browser Back Button
What's the Valid Way to Include an Image With No Src
Input Type Image Submit Form Value
Flex Container Min-Height Ignored in Ie
How to Get Box-Shadow on Left & Right Sides Only
How to Make a Whole Row in a Table Clickable as a Link
How to Get This CSS Text-Decoration Override to Work
Css Two Divs Next to Each Other
How to Specify Line Breaks in a Multi-Line Flexbox Layout
How to Change Source of ≪Img≫ Tag on Hover
What's the Difference If I Put CSS File Inside ≪Head≫ or ≪Body≫
≪Code≫ VS ≪Pre≫ VS ≪Samp≫ For Inline and Block Code Snippets