js点击按钮保存数据到本地

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>05_淡入淡出动画效果</title>
</head>
<body>
<input id="add" type="button" value="添加" /> <script src="http://code.jquery.com/jquery-1.4.1.min.js"></script>
<script> $("#add").bind("click", function () {
var content = "123123"
var fileName = 'test.pem'
var aLink = document.createElement('a');
var blob = new Blob([content]);
var evt = document.createEvent("HTMLEvents");
evt.initEvent("click", false, false);
aLink.download = fileName;
aLink.href = URL.createObjectURL(blob);
aLink.dispatchEvent(evt);
aLink.click();
}) </script>
</body>
</html>
上一篇:JAVA编程心得-Eclipse/MyEclipse 中文乱码解决办法


下一篇:[UE4]蓝图函数库