【发布时间】:2013-02-02 17:36:54
【问题描述】:
编辑:
基本上我想要一个嵌入了 javascript 或 Jquery 的 Html 文件,它可以直接访问 SDCARD 内容,同时在浏览器中打开它(因为它是一个 html 文件)。因为它可以通过我发布的活动访问它的代码,但我想直接点击 SDCARD 文档,而不是从 android 应用程序。
发布:
我有一个存储在 SD 卡中的 HTML 文件,其中包含用于访问 SD 卡内容的 javascript 代码。
我已经从 Activity 和 webView 测试了相同的代码,并且工作正常,但我想要 content to be displayed on directly clicking on HTML Link 而不是通过 Activity。
有什么方法可以写Android permissions in HTML CODE.或者我如何使用 HTML、JavaSCRIPT 或 JQUERY 等直接访问它。
代码如下:
<!DOCTYPE HTML>
<html>
<head>
<title>Cordova</title>
<script type="text/javascript" charset="utf-8" src="cordova-2.2.0.js"></script>
<script type="text/javascript" charset="utf-8">
var edt=document.getElementById("")
function getFileSystem() {
window.LocalFileSystem = window.requestFileSystem
|| window.webkitRequestFileSystem;
alert("====== hey its me===");
window.requestFileSystem(1, 0, onFileSystemSuccessUpload, fail);
}
function fail() {
console.log("Error getting system");
}
function onFileSystemSuccessUpload(fileSystem) {
// get directory entry through root and access all the folders
var directoryReader = fileSystem.root.createReader();
// Get a list of all the entries in the directory
directoryReader.readEntries(successReader, fail);
}
function successReader(entries) {
var i;
for (i = 0; i < entries.length; i++) {
//alert(entries[i].name);
document.write("<p>" + entries[i].name+"</p>");
//document.getElementById("text1").innerHTML = "" + entries[i].name;
if (entries[i].isDirectory == true) {
var directoryReaderIn = entries[i].createReader();
directoryReaderIn.readEntries(successReader, fail);
}
}
}
</script>
</head>
<body>
<a onclick="getFileSystem()" href="javascript:void(0);">Click here to View File System</a>
</body>
</html>
cordova.js 与 html 文件一样保存在并行目录中../
【问题讨论】:
标签: javascript android jquery html browser