为了账号安全,请及时绑定邮箱和手机立即绑定

html怎么将input数据通过js保存到本地txt文件中

html怎么将input数据通过js保存到本地txt文件中

木亦Sam 2016-07-22 10:27:36
<!DOCTYPE html> <html> <head>   <meta charset="UTF-8">   <title>Document</title> </head> <body> <textarea name="wenben" id="wenben" cols="100" rows="10">000</textarea> <input type="button" value="Save" onclick="saveText()">    <script>    function saveText()  {    var strHTML= document.getElementById("wenben").value;//获取内容      var winSave=window.open();     winSave.document.open("text","gb2312");     winSave.document.write(strHTML);     winSave.document.execCommand("SaveAs",true,"newfile.txt");   window.location.href="#"  ;   winSave.close();    }    </script> </body> </html>上面的代码为什么不行?
查看完整描述

1 回答

?
qq_二冬_0

TA贡献8条经验 获得超7个赞

document的execCommand方法是ie独有的吧,所以你这段代码在ie下是可以实现的,其他浏览器可能需要别的方式去实现

查看完整回答
3 反对 回复 2016-07-22
  • 1 回答
  • 0 关注
  • 20119 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信