.html格式文件的下载

.html下载本地

通过javascript实现

index.html

<ahref=#onclick="window.open('temp.html');return(false);">下载文件</a>

#######

temp.html//被下载文件

<Scriptlanguage="javascript">
if(typeof(window.opener)!='undefined')//判断打开方式的下载。去掉会一打开文件就弹出下载框
{
document.execCommand('SaveAs');
window.close();
}
</Script>

################

<buttononclick="javascript:document.execCommand('SaveAs');">保存本页面</button>

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