عند تنزيل الملفات على صفحات الويب ، تكون الملفات في بعض الأحيان كبيرة جدًا وتستغرق بعض الوقت حتى يتم إنشاء الملف. في هذا الوقت ، لمنع المستخدمين من إجراء عمليات أخرى على صفحة الويب ، تتمثل إحدى الطرق في استخدام Div للكتابة فوق صفحة الويب وقفل صفحة الويب.
دالة lockscreen () {swidth = $ (window) .width () ؛ snight = $ (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: dimizageTransform.Microsoft.alpha (style = 3 ، opacity = 25 ، finispacity = 75" ؛ bgobj.style.opacity = "0.6" Bgobj.Style.استخدم الوظيفة أعلاه لقفل الصفحة لمنع عمليات متعددة ، وإلغاء شاشة القفل حتى يظهر مربع التنزيل.
قم بتعيين ملفات تعريف الارتباط في جانب الخادم (CGI):
<pre name = "code"> char *configDownloadToken = "HESTDOWNOLDFILE" ؛ printf ("نوع المحتوى: التطبيق/actet-stream/ncontent-length: ٪ ld/n" ، s.st_size) ؛ printf ("set-cookie: configDownloadToken = ٪ s ؛ path =/؛/r/n" ، configDownloadToken) ؛ printf ("disposition content: filename =/" ٪ s/"/n" ، strrrchr (filename ، '/') + 1) ؛ printf ("الاتصال: إغلاق/n/n") ؛استيراد المكون الإضافي jquery.cookie.js على العميل (HTML ، JS) ، وقم بتضمين هذا البرنامج المساعد في ملف HTML ، واحصل على ملفات تعريف الارتباط بانتظام في ملف JS
var configDownloadCheckTimer ؛ $ (document) .Ready (function () {configdownloadCheckTimer = window.setInterval (function () {var cookeavalue = $ .cookie ('configdownloadtoken') ؛ if (cookievalue === "HESTDOWNOLDFILE") Function FinishDownload () {window.clearinterval (configdownloadCheckTimer) ؛ $ .removeCookie ('configDownloadToken') ؛ // مسح قيمة ملفات تعريف الارتباط هذه}هذا كل شيء.