How to Prevent users from performing other operations on the webpage during file download on the webpage _ jquery

Source: Internet
Author: User
It takes some time for a webpage to download files. During this period, how does one prevent users from performing other operations on the webpage, overwrite the div on the webpage, and lock the webpage, sometimes the file is too large and it takes some time to generate the file. To prevent other operations on the webpage, you can use a p to overwrite the webpage and lock the webpage.

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

Use the above function to lock the page to prevent multiple operations. You need to cancel the screen lock when the download box appears.

Set the cookie on the server (cgi:

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

Import the jquery. cookie. js plug-in on the client (html, js). Include this plug-in the html file, and regularly obtain the cookie in the js file.

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 } 

In this way, you can.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.