账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    JS文件下载,将文件下载到浏览器沙箱报错
    52
    0

    代码如下:

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <title>Document</title>
    </head>
    <body>
        <input name="download" id="download" />
        <button type="button" onclick="down()">下载文件</button>
    </body>
        <script>
            function down() {
                window.webkitRequestFileSystem(Window.TEMPORARY,1024*1024,function(fs) {
                    var fileEntry = fs.root.getFile("Test.txt",{create: true});
                    var fileWriter = fileEntry.createWriter();
                    fileWriter.seek(10);
                    var blob = new Blob(["hello,the world"]);
                    fileWriter.write(blob);
                    console.log("Successfuly")
                },(err) => {
                    console.log(err);
                });
            }
    
        </script>
    </html>

    浏览器报错:

    DOMException: It was determined that certain files are unsafe for access within a Web application, or that too many calls are being made on file resources.
    0
    打赏
    收藏
    点击回答
        全部回答
    • 0
    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部