美文网首页全栈开发技术
JavaScript中如何保存输入到本地

JavaScript中如何保存输入到本地

作者: felix1982 | 来源:发表于2017-12-18 09:53 被阅读8次
    function saveSqlToLocal() {
                var textToSave = sqlEditor.getValue();
                var textToSaveAsBlob = new Blob([textToSave], { type: "text/plain" });
                var textToSaveAsUrl = window.URL.createObjectURL(textToSaveAsBlob);
                var downloadLink = document.createElement("a");
                downloadLink.download ="文件名";
                downloadLink.href = textToSaveAsUrl;
                downloadLink.onclick = destroyClickedElement;
                downloadLink.style.display = "none";
                document.body.appendChild(downloadLink);
    
                downloadLink.click();
            };~~~

    相关文章

      网友评论

        本文标题:JavaScript中如何保存输入到本地

        本文链接:https://www.haomeiwen.com/subject/zxppwxtx.html