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();

}

  

猜你喜欢

转载自www.cnblogs.com/Leechg/p/9953617.html
今日推荐