如何在html网页中实现点击一个按钮保存网页上textbox文本框中内容到本地的一个txt文件

网页中有一个按钮,一个文本框,在<SCRIPT language=JavaScript> /SCRIPT>当中如何写代码能够实现这个功能,谢谢!

<html>
<head>
<title>无标题文档</title>
</head>

<body>
<form name="form1" method="post" action="">
<input type="text" name="textbox1">
<input type="button" name="btn1" value="按钮" onClick="savefile('newfile.txt',this.form.textbox1.value)">
</form>
<script language="JavaScript" type="text/javascript">
function savefile(SaveFileName,data)
{
var newWin = window.open("","DownLoad","");
newWin.document.write(data)
newWin.document.execCommand('Saveas',true, SaveFileName);
newWin.window.close();
}
</script>
</body>
</html>
温馨提示:答案为网友推荐,仅供参考
相似回答