JS下载文件

function load1() {
	window.URL = window.URL || window.webkitURL;
	var xhr = new XMLHttpRequest();
	xhr.open('GET', 'git.docx', true);
	xhr.responseType = 'blob';
	xhr.onload = function (e) {
		if (xhr.status === 200) {
			window.location.href = window.URL.createObjectURL(this.response);
		} else {
			console.log("CORS failed. Check Internet Connection.")
		}
	};
	xhr.send();

}

  

posted @ 2018-11-13 18:01  leechg  阅读(199)  评论(0编辑  收藏  举报