Windows和Android的之间的冲突? [英] Conflict between Windows and Android?

查看:125
本文介绍了Windows和Android的之间的冲突?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请帮我解决这个文件路径冲突:

Please help me solve this file path conflict:

如你所知,许多HTML页面使用相对路径开始以/为链接标记的href属性。例如:链接HREF =/链接/ style.css的

As you know, many HTML pages use relative paths starting with a "/" for the href attribute of link tags. For example: link href="/links/style.css".

在我的code,我使用<一个href=\"http://developer.android.com/reference/android/webkit/WebView.html#loadDataWithBaseURL%28java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String%29\"相对=nofollow> loadDataWithBaseURL 了的WebView设置一个相对路径名。如果我给这样的:

In my code, I'm using loadDataWithBaseURL for a WebView to set a relative path name. If I give like this:

String webContent=//whole html page;
mWebView.loadDataWithBaseURL("file:///sdcard/mibook/pg90/",new String(webContent), "text/html", "UTF-8","" );

结果:在WebView中不起作用,因为(我觉得)它需要两个/,同时附加到路径

如果我从href标记删除第一个/编辑我的HTML页面,则呈现网页视图正确。

If I edit my HTML page by removing the first "/" from the href tag, then the WebView renders properly.

但我的问题是,我不希望编辑如上HTML内容。任何解决方案?

But my problem is that I don't want to edit HTML content as above. Any solution?

推荐答案

的<一的Javadoc href=\"http://developer.android.com/reference/android/webkit/WebView.html#loadDataWithBaseURL%28java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String%29\"相对=nofollow> loadDataWithBaseURL 状态:

Note for post 1.0. Due to the change in the WebKit, the access to asset files through   
"file:///android_asset/" for the sub resources is more restricted. If you provide null 
or empty string as baseUrl, you won't be able to access asset files. If the baseUrl is
anything other than http(s)/ftp(s)/about/javascript as scheme, you can access asset 
files for sub resources

因此​​,对于基本上只允许网址的file:/// 方案是的file:/// android_asset / 其中,文件在您的资产文件夹中。

So basically only allowed URL for file:/// scheme is file:///android_asset/ where files are in your asset folder.

这篇关于Windows和Android的之间的冲突?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆