- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
为了轻松更新我的应用程序,我将 www 文件夹的内容复制到手机,然后执行 window.location = workingDirectory.toURL() + "/index.html"
.
编辑 - 请注意,这在 Phonegap 3.4 之前有效,但在 3.5 上无效(当我尝试更改位置时似乎没有任何反应)。如果不是 toURL
我用 toNativeURL
,那么它也适用于 3.5。 使用toNativeURL
还修复了 iOS 上的当前问题。
复制所有文件并打开索引在 iOS 和 Android 上都可以正常工作。但 iOS 上的问题是页面绝对没有样式,就好像 CSS 文件的链接不起作用一样。在 Android 上一切正常。
我的链接是相对的(例如 <link href="css/reseter.css" rel="stylesheet">
)。指向其他页面或脚本的链接有效。
这是我打开的简化主页:
<!DOCTYPE html>
<html>
<head>
<title></title>
<link href="style.css" rel="stylesheet">
<script src="main.js"></script>
</head>
<body>
<div class="red">I should be red but I'm not!</div>
<a href="page2.html">This correctly takes me to the other page.</a>
</body>
</html>
样式.css
.red { color: red; }
主要.js
alert("HELLO is correctly displayed");
我正确地得到了 alert
(它的标题是 cdvfile://localhost/
)我也可以正确地转到 page2.html
.唯一的问题是样式。
如果我在 Safari 中打开指向我的电脑的页面,样式会正确显示。
我尝试了一些方法,但无济于事:
<base href="cdvfile://localhost/persistent/MyApp/">
在<head>
<link href="cdvfile://localhost/persistent/MyApp/css/reseter.css" rel="stylesheet">
)最佳答案
我终于通过使用 fileSystem.root.fullPath
让它在 PhoneGap 2.9 中工作。在 PhoneGap 3.3 上,它只返回 /
。这是 PhoneGap 3.3 上的一个错误吗?当使用 cdvfile 时,除了 CSS 文件之外,一切似乎都有效吗?
我决定暂时使用相对路径我在 PhoneGap 3.3 上的 iOS 应用程序:../../Documents/MyApp/index.html
。我不知道使用它是否安全。
编辑 在 Phonegap 3.5(我没有在 3.3 中测试过),使用 work window.location = workingDirectory.toNativeURL() + "/index. html";
(即 使用 toNativeURL
而不是 toURL
)有效。
关于ios - 链接到本地文件(cdvfile ://) on iOS PhoneGap 3. 3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22801511/
问题: 在我的应用程序中,我想通过 cordova wkwebview 访问图像。HTML 元素如下所示。 加载时,出现错误“无法加载资源:不支持的 URL”。我正在使用 iOS 10.2。 已验证
为了轻松更新我的应用程序,我将 www 文件夹的内容复制到手机,然后执行 window.location = workingDirectory.toURL() + "/index.html" . 编辑
我目前正在使用 phonegap 开发一个应用程序,我想更新我在 wordpress 上的应用程序的内容。通过 JSON API,我获得了页面的 html 内容,但问题是让用户选择图像。我所做的是从
我正在使用 cordova-plugin-camera 通过这些选项拍照: quality: 100, destinationType: Camera.DestinationType.NATIVE_U
我在 angular/ionic/cordova 应用程序中显示下载到 cordova.file.dataDirectory 的图像时遇到问题。 我正在使用 cordova-plugin-file,我
我目前正在探索在我正在构建的应用程序上存储文件的不同选项,但是我注意到手机间隙中存在不同的文件结构,并且不知道哪个是最新的。 使用: alert(JSON.stringify(fileSystem.r
我的应用程序使用 FileAPI 复制设备上的文件.这在 Phonegap 3.4.0 和 3.5.0 中运行良好。 然后它通过执行 window.location = "cdvfile://loca
我的 Cordova 应用程序从服务器下载音频文件,并使它们可以在设备离线时播放。直到昨天我升级到最新版本时一切正常。 最初,下载(通过文件传输插件)和播放(通过媒体插件)都不起作用。进一步研究我发现
我是一名优秀的程序员,十分优秀!