Ton*_*ny2 10 javascript html5 html5-filesystem
我正在尝试Firefox,IE 9,Chrome和Opera下面的代码,但是onInitFs(fs)函数没有被调用.如果我在window.requestFileSystem中添加'()'到onInitFs(window.PERSISTENT,1024*1024,onInitFs,errorHandler)该函数被调用但fs为null?有谁知道如何解决这个问题?我试试Windows 7.我非常感谢你的帮助.
<!DOCTYPE HTML>
`<html>
<head>
<script>
function errorHandler(e){
alert("errorrrr");
}
function onInitFs(fs){
alert("onInitFs");
}
function readClick(){
if (window.webkitRequestFileSystem) {
window.webkitRequestFileSystem(window.PERSISTENT, 1024*1024,onInitFs,errorHandler);
}
else {
window.requestFileSystem(window.PERSISTENT, 1024*1024, onInitFs, errorHandler);
}
alert("read finishsssss");
}
</script>
</head>
<body>
<input type="button" value="Read dir" onclick="readClick()">
<ul id="filelist"></ul>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
Ray*_*nos 14
只有chrome支持requestFileSystem
作为webkitRequestFileSystem
版本.
其他浏览器(FF6,IE9,Op11)都不支持此功能
考虑到无法通过网站“浏览”本地文件的安全性问题,应该回答您的问题:
请求PERSISTENT文件系统时,您必须首先请求配额。尝试改用:
window.storageInfo.requestQuota(PERSISTENT, 1024*1024,
function(grantedBytes) {
window.requestFileSystem(window.PERSISTENT, grantedBytes, onInitFs, errorHandler);
},
errorHandler
);
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
30371 次 |
最近记录: |