<!doctype html>javascript
<html class="no-js">html
<head>java
<meta charset="utf-8">web
<title>ajax</title>ajax
<meta http-equiv="X-UA-Compatible" content="IE=edge">chrome
<meta name="description" content="">api
<meta name="keywords" content="">app
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">測試
<!-- Set render engine for 360 browser -->ui
<meta name="renderer" content="webkit">
<!-- No Baidu Siteapp-->
<meta http-equiv="Cache-Control" content="no-siteapp"/>
<!--<script type="text/javascript" src="http://api.map.baidu.com/api?v=1.5&ak=mVXVL4BToC5F7LZYE5ARS5ON"></script>-->
</head>
<body>
<div>
進度:<span id='progress'>0%</span><br/>
<button onclick="download()">開始下載</button>
</div>
<script type="text/javascript">
var http=new XMLHttpRequest(),//新建一個HTTP請求對象
progress=document.getElementById('progress');//顯示進度
function download(){
http.open('GET','./dowload.zip',true);
http.onreadystatechange=function(){
if(http.readyState===4){
progress.innerHTML='ok';
};
}
//監聽下載進度變化事件
http.addEventListener('progress',function(evt){
if(evt.lengthComputable){
var percent=parseInt((evt.loaded/evt.total)*100);//計算百分比
progress.innerHTML=percent+'%';
}
},false);
http.send();
}
</script>
</body>
</html>
chrome測試經過