直接从Android文件管理器打开html页面时如何正确设置背景图像的绝对路径

Posted

技术标签:

【中文标题】直接从Android文件管理器打开html页面时如何正确设置背景图像的绝对路径【英文标题】:How to correctly set the absolute path of a background-image when opening an html page directly from Android File Manager 【发布时间】:2019-09-01 09:35:06 【问题描述】:

我正在使用 android 中的 droidEdit 创建一个简单的 html 页面,就这么简单。 在此页面中,有一个带背景的 div。 此背景是本地存储的图像,但 url 必须(出于多种原因)是绝对路径,而不是相对路径,尤其是这样的:file:///sdcard/assets/images/test.gif

现在,如果我打开我的页面打开 Chrome 并导航到 file:///sdcard/index.html 一切正常,我可以看到我的 div 和他漂亮的动画背景。 我的问题是,如果我直接从文件管理器打开 index.html,Chrome 会启动并正确显示 index.html,但 div 根本不显示背景。

我不是 Android 系统如何在表面下工作的专家,但由于相同的代码(当然具有不同的 file:/// 路径)在 Windows 中工作,我怀疑 Android 不知何故使用了不同的 url /uri 系统来处理本地存储的文件。

当我直接从文件管理器打开 index.html 时,有什么方法可以设置 test.gif 的正确(绝对)路径以使 css 正确加载它?

提前谢谢你

【问题讨论】:

能不能把有背景的index.html文件加进去? 可惜我现在不在电脑前,但是我在一个项目的开始,所以目前html文件基本只有一个div,css只有背景-图像规则;-) 【参考方案1】:

在 chrome 中直接导航到文件时,可以访问本地图像。由于浏览器施加的安全规则,从另一个页面打开 html 文件时它将不起作用。在此处查看完整的详细信息:https://blog.chromium.org/2008/12/security-in-depth-local-web-pages.html

可以通过使用任何在线工具(搜索base64 image)对图像进行base64编码并使用结果作为背景来修复:

body
  background: url('data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBxMTEhUTExIVFhUXGRgYFxgXGBcXFhgXFxUXFxcXGBcYHSggGBolGxUXITEhJSkrLi4uFx8zODMtNygtLisBCgoKDg0OGxAQGy0lICYvLi0tLS0tLS0tLystLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLf/AABEIAKgBKwMBIgACEQEDEQH/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+jRKTUbQHdd6kZMZERJ6zA5pUauCAZcJYBuTBzj0CwvIRbtIVZpVQ97MV26gwsOrJycb5gdU+4lfFow2V5eXo4ckvwWvsfD85bKbxnirTh7SJnJ+Xy5Sqle1+83SAfsM8x1zsvLyhHb2bl0acMrfEqBswBIecQGjOozyGcJ3c0y9/wALLaNNmqnpzLNBd8Tlqc7f6cl5eVq1/glKWwK7rRTpU55GpjY6zgn/AOIHutbCx1hzzIYwSeUk4aBGdyJjkvLylHqxYv4/79k1KiC8VHTpe5rWcpcMcsYA9MKxXTKT6Omo4BtQaA48pyD5ggLK8lkvR0pNlNfwRra2l5LRTo/Eq57xIaXEN6HvNaD1cmPZ2lW0AhjG63RJHyUmg6omSdXyyTMNdyK8vKkHyhFv2LKT43/Q44dUOkt0ul5aMgTpHe2Bgciek+Ce2sNgAz5ecfzyXl5Jjk3Nr6Qrk0n/AGR9orP4jmDGQTpMQTgnl0HhukN1ww9w1HAVc/5YHdbnDIy0wY1RywvLybyF8tGLIttmLmKYy54BAhrNbtIaADI2bnfqhrhprNDAZ1OIwCNRIEYO5g8uqyvKUNv+xOJ5tGnQwXCpUPzuHygZYWg7OOTJOMY6oW3vHtf3st1AGBEdR5wZnmDPVeXkJPYr7G9ag0kBzAWkzMSBAAJPTrKDcxrXbnW505yG6+YI/wBQzO0Ly8pQ6s5m1pc99xP9paZzmM59UzuqTWuDWzJG+I1kAxPMwD4ZHkvLy5Aj0Am7FN0ZDW5EQC0jY9TucdQvVajS9xBDQcQNtpI25umMbALy8i36OZmnEanuJgNa2DAeWxOPDHsk12Q97nOOSZ6Y5fSFleQjti2f/9k=')

或将背景图片上传到任何图片托管服务并引用网址。

【讨论】:

感谢您的回答 :-) 但是,为什么在 Windows 中可以两种方式工作:要么我从 Chrome 打开 index.html,要么直接打开它?我的意思是,没有不同的页面,它是同一个页面,不是吗? 页面没有差异,是android和桌面/windows的安全配置差异造成的。 Android 处理加载本地图像的方式更严格地限制攻击面(查看博客)。不加载背景图像以防止安全问题。 @Revenant 这是否解决了您的问题,如果可以,您可以将其标记为答案吗? @Revenant

以上是关于直接从Android文件管理器打开html页面时如何正确设置背景图像的绝对路径的主要内容,如果未能解决你的问题,请参考以下文章

android软键盘弹出时如何处理页面布局

首次打开页面时如何为 div 的大小调整设置动画 [重复]

在Google Cloud中部署Python App时如何处理打开文件的路径?

通过浏览器直接打开Android应用程序

如何直接从我的 Android 应用程序打开 Amazon AppStore?

vscode如何运行html页面?