블로그 이미지

calendar

1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
  • total
  • today
  • yesterday
2013. 2. 21. 14:53 HTML
다운로드시 브라우저가 멈춘다는 것을 이용한 체크방법
  1.     
  2. var lastTime = new Date().getTime();  
  3. function checkTime() {  
  4.     var curTime = new Date().getTime();  
  5.     if (curTime - lastTime > 1100) { // 1100 because there might be small browser lags   
  6.         // do something after the dialog appeared and the user did something with it  
  7.     }  
  8.     lastTime = curTime;  
  9. }  
  10. setInterval(checkTime, 1000);  
쿠키를 이용한 체크 방법
  1.     
  2. var checkDowloadInteval = null;  
  3. var token=null;  
  4. function fileUploader(){      
  5.     token = new Date().getTime();  
  6.         //hd_token 이라는 hidden input box에 토큰값을 셋팅한후 form으로 감싼후(get으로 보내도됨) 서버로 데이터를 보낸다  
  7.     $("#hd_token").val(token);  
  8.         //1초마다 서버에서 데이터를 보냈는지 확인함  
  9.     checkDowloadInteval = setInterval(checkCookie, 1000);  
  10.         //해당 폼 서브밋  
  11.     j$('#fmFileUpload').submit();  
  12. }  
  13.   
  14. function checkCookie() {  
  15.     //서버에서 클라이언트에게 보낸 데이터에서 download라는 쿠키키가 있는지 확인하고 값이 맞는지 확인  
  16.     if (document.cookie.indexOf("download=" + token) > -1) {     
  17.         //1초마다 체크하는것 제거  
  18.         clearInterval(checkDowloadInteval);  
  19.           
  20.        //여기서 다운로드 실행  
  21.          
  22.     }  
  23.       
  24. }  
쿠키를 이용한 체크 방법
  1.     
  2. HttpServletResponse response = ServletActionContext.getResponse();  
  3. Cookie cookie = new Cookie("download",token);  
  4. response.addCookie(cookie);  
posted by 천상의날개