如何在Android 10上使用html文件中的超链接引用本地文件?

问题描述 投票:0回答:1

我在基于 Android 10 的智能手机上的同一目录中创建了两个名为“file1.html”和“file2.html”的 html 文件。 file1.html 包含以下超链接:

<a href="file2.html">Relative link to file 2</a>

但是当我在浏览器中打开 file1.html 并单击链接时,我会看到“找到文件注释”消息。 在较旧的 Android 版本上它运行良好。

用绝对链接替换链接:

<a href="/storage/emulated/0/Documents/file2.html">Absolute link to file 2</a>

对 Firefox 浏览器有帮助,但对其他浏览器(Chrome、Opera、Dolphin 等)仍然失败。

有什么想法至少可以解决 Chrome 和 Opera 的问题吗?

android html google-chrome firefox hyperlink
1个回答
0
投票

使用 file:// 协议链接到文件:

<a href="file:///storage/emulated/0/Documents/file2.html">Absolute link to file 2</a>

还要确保应用程序具有权限

READ_EXTERNAL_STORAGE

© www.soinside.com 2019 - 2024. All rights reserved.