![](/img/trans.png)
[英]How to display a loading screen image until the redirected page loads fully?
[英]How to display page loader from the time button is submitted until the redirected page completes loading
當用戶單擊“提交”按鈕時,我嘗試使用帶有gif圖像的普通覆蓋層實現頁面加載器。 提交按鈕將執行一個asp.net回發,然后重定向到另一個頁面。 該頁面可能執行回發以進行一些數據檢索。
當前,當重定向頁面顯示時,頁面加載器將消失,因為頁面仍在執行某些數據檢索。
如何保持頁面加載器顯示直到重定向頁面完全加載?
目前,我使用此代碼顯示加載程序
$('form').on('submit', function(){showLoader()});
這是您無法從父頁面執行的操作。 原因是,只要您將頁面重定向到其他域,該域的內容就會被加載。 因此,無法使加載程序與前一頁保持一致。
您可以嘗試的是,顯示一些在頁面加載之前顯示加載程序的功能。 並在通過父窗口打開頁面時嘗試調用它。
我想您已經使用了母版頁/內容頁結構。 為此,您可以嘗試在母版頁上遵循以下代碼。
window.onbeforeunload = showLoader;
function showLoader() {
var id = '#overlay_form';
var maskHeight = $(document).height();
var maskWidth = $(window).width();
$('#mask').css({ 'width': maskWidth, 'height': maskHeight });
$('#mask').fadeIn(1000);
$('#mask').fadeTo("slow", 0.4);
var winH = $(window).height();
var winW = $(window).width();
$(id).css('top', (winH / 2 - $(id).height() / 2 - 20));
$(id).css('left', winW / 2 - $(id).width() / 2);
$(id).fadeIn(2000);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.