最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

網(wǎng)頁下載文件期間如何防止用戶對(duì)網(wǎng)頁進(jìn)行其他操作

 更新時(shí)間:2014年06月27日 17:36:35   投稿:whsnow  
網(wǎng)頁下載文件時(shí)需要一段時(shí)間,在這期間如何防止用戶對(duì)網(wǎng)頁進(jìn)行其他操作,將div覆蓋在網(wǎng)頁上,將網(wǎng)頁鎖住,具體實(shí)現(xiàn)如下

做網(wǎng)頁下載文件時(shí),有時(shí)候文件過大,生成文件需要一段時(shí)間。這個(gè)時(shí)候要防止用戶對(duì)網(wǎng)頁進(jìn)行其他操作,有種方法就是使用一個(gè)div覆蓋在網(wǎng)頁上,將網(wǎng)頁鎖住。

function lockScreen() 
{ 
sWidth=$(window).width(); 
sHeight=$(window).height(); 
var bgObj=document.createElement("div"); 
bgObj.setAttribute('id','bgDiv'); 
bgObj.style.position="absolute"; 
bgObj.style.top="0"; 
bgObj.style.background="#CCCCCC"; 
bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75"; 
bgObj.style.opacity="0.6"; 
bgObj.style.left="0"; 
bgObj.style.width=sWidth + "px"; 
bgObj.style.height=sHeight + "px"; 
if(sWidth < 860) 
{ 
bgObj.style.width="860px"; 
} 
bgObj.style.zIndex = "10000"; 
document.body.appendChild(bgObj); 
}

使用如上函數(shù)可以鎖住頁面防止多次操作,要直到下載框出現(xiàn)時(shí)取消鎖屏。

在服務(wù)器端(cgi)中設(shè)置cookie:

<pre name="code" class="cpp">char *configDownloadToken = "finishedDownloadFile"; 
printf("Content-Type: application/octet-stream\nContent-Length: %ld\n", s.st_size); 
printf( "Set-Cookie:configDownloadToken=%s; path=/; \r\n ",configDownloadToken); 
printf("Content-Disposition: attachment; filename=\"%s\"\n", strrchr(filename,'/') + 1); 
printf("Connection: close\n\n");

在客戶端(html、js)導(dǎo)入插件jquery.cookie.js,在html文件中要包含此插件,js文件中定時(shí)獲取cookie

var configDownloadCheckTimer; 
$(document).ready(function () { 
configDownloadCheckTimer = window.setInterval(function() { 
var cookieValue = $.cookie('configDownloadToken'); 
if (cookieValue === "finishedDownloadFile") 
{ 
refreshPage(); 
finishDownload(); 
} 
}, 1000); 
}); 

function finishDownload() { 
window.clearInterval(configDownloadCheckTimer); 
$.removeCookie('configDownloadToken'); //clears this cookie value 
} 

這樣就可以了。

相關(guān)文章

最新評(píng)論

巨野县| 丰台区| 西昌市| 澎湖县| 公安县| 萍乡市| 玛多县| 英山县| 贺州市| 石河子市| 增城市| 南木林县| 合作市| 铜山县| 沁源县| 连云港市| 沙坪坝区| 固镇县| 乃东县| 永宁县| 渭源县| 湘阴县| 五大连池市| 渭南市| 沙坪坝区| 南城县| 颍上县| 台东县| 邛崃市| 长葛市| 安图县| 古交市| 贵阳市| 正蓝旗| 宣恩县| 鄂伦春自治旗| 聊城市| 静海县| 鸡西市| 绥棱县| 民权县|