活学活用,让txt文件也能一点就另存为下来

<html>
<head>
<title>save chat</title>
<script type="text/javascript" src="prototype.js"></script>
<script type="text/javascript">
function saveas(url) {
new Ajax.Request(url,{
method:"GET",
onSuccess:function(transport){
try {
var winSave = window.open();
winSave.document.open("text/plain","GBK");
winSave.document.write(transport.responseText);
winSave.document.execCommand ("SaveAs",true,url);
winSave.close();
}
catch(e){}
},onFailure:function(transport){
alert(transport.responseText);
}
});
return false;
}
</script>
</head>
<body>
下载222.txt

直接打开 222.txt
</body>
</html>

你可能感兴趣的:(JavaScript,html,Ajax,prototype)