<!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;//獲取內(nèi)容
??
??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>上面的代碼為什么不行?
html怎么將input數(shù)據(jù)通過js保存到本地txt文件中
木亦Sam
2016-07-22 10:27:36