网页上点击按钮,打开“另存为”的对话框。
function DownLoad()
{
var dialog = new ActiveXObject("MSComDlg.CommonDialog");
dialog .Filter = "Microsoft Office Excel(*.xls)|*.xsl";
dialog .FilterIndex = 2;
//必须设置MaxFileSize. 否则出错
dialog .MaxFileSize = 128;
//显示对话框
dialog.ShowSave();
}
测试前端页面
<html>
<head>
</head>
<body>
<button onclick="DownLoad()">测试</button>
</body>
</html>
</script>