Webページにファイルをダウンロードすると、ファイルが大きすぎてファイルが生成されるまでに時間がかかる場合があります。この時点で、ユーザーがWebページで他の操作を実行できないようにするために、1つの方法は、DIVを使用してWebページを上書きしてWebページをロックすることです。
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:dimbyagetransform.microsoft.alpha(style = 3、ofacity = 25、finantopacity = 75"; bgobj.style.opacity = "0.6"; bgobj.style.left = "0"; bgobj.style.width = swidth + "px" bgobj.style.height + "px";上記の関数を使用してページをロックして複数の操作を防ぎ、ダウンロードボックスが表示されるまでロック画面をキャンセルします。
サーバー側(CGI)にCookieを設定します。
<pre name = "code"> char *configdownloadtoken = "finenddownloadfile"; 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)にプラグインjquery.cookie.jsをインポートし、HTMLファイルにこのプラグインを含め、JSファイルで定期的にCookieを取得します
var configdownloadchecktimer; $(document).ready(function(){configdownloadchecktimer = window.setInterval(function(){var cookievalue = $ .cookie( 'configdownloadtoken'); if(cookievalue == "finiteddownloadfile"){refinesspage(); finitsownload();}};};}); function finishtownload(){window.clearinterval(configdownloadchecktimer); $ .REMOVECOOKIE( 'configdownloadtoken'); //このクッキー値をクリアする}それだけです。