用js保存页面指定内容、指定文件类型

<script language=javascript>   

function Save(){   
    var txt = document.all.output.value;
    b = window.open();  
    b.document.open();  
    b.document.write(txt);  
    b.document.close();
    b.document.execCommand('saveas',true,'output.html');
    b.window.close();
}

</script>
 


<center>仅保存文本框中部分:</center>
<table width="90%" align="center" border="0" cellpadding="0" cellspacing="0"> 
    <tr> 
		<td>不保存</td> 
		<td><input type="button" value="Save" class="trans" onclick="Save()">

		<textarea rows="20" cols="50" id="output" class="txtedit"></textarea>
		</td> 
    </tr> 
</table>
 

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