2009-11-20 32 views
0

我有一個Home.html,有一個登錄表單,登錄.aspx login.aspx需要很多時間加載...javascript只加載之前aspx ...像gmail.com登錄加載器

所以我想有一個基於JavaScript的功能,其中我點擊登錄按鈕, 加載程序必須顯示...而在後臺POST發生,然後aspx頁面必須加載,然後模態必須重定向到aspx頁面。

類似於gmail.com登錄加載器.....但只使用JavaScript。 (我也使用縮小jQuery js)(沒有aspx頁之間)

請注意,我不能使用任何基於asp的加載程序!

我已經嘗試使用:

http://blogs.msdn.com/naitik/archive/2008/07/31/show-loading-message-while-web-page-is-processing.aspx
(它不工作速度快首先重定向到張貼頁。)提前

謝謝..

回答

0

如果你只是想展示一個「請稍候......」,將自己附在表格「onsmit」事件上。然後顯示「請稍候」消息(使DIV可見)。完成後,表單將被提交併等待login.aspx。

如果你想有一個進度條,你有兩種方法: *發佈到一個隱藏的iframe,它將加載login.aspx。 *或使用XmlHttpRequest加載login.aspx。

在這兩種情況下,login.aspx必須吐出更新進度條的消息(您在客戶端上解釋的JScript或DIV片斷)。

您會在Google中找到大量示例。例如,嘗試「jscript progress bar aspx」。

0

看看下面的鏈接,因爲它是一個「裝載機」所需要的代碼,造型和佈局。

我已經使用的代碼和它的作品100%

你需要一個div您的網頁上:

<div class="modal"></div> 

的DIV了CSS樣式的:

/* Start by setting display:none to make this hidden. 
Then we position it in relation to the viewport window 
with position:fixed. Width, height, top and left speak 
speak for themselves. Background we set to 80% white with 
our animation centered, and no-repeating */ 
.modal { 
    display: none; 
    position: fixed; 
    z-index: 1000; 
    top:  0; 
    left:  0; 
    height:  100%; 
    width:  100%; 
    background: rgba(255, 255, 255, .8) 
       url('http://sampsonresume.com/labs/pIkfp.gif') 
       50% 50% 
       no-repeat; 
} 

/* When the body has the loading class, we turn 
    the scrollbar off with overflow:hidden */ 
body.loading { 
    overflow: hidden; 
} 

/* Anytime the body has the loading class, our 
    modal element will be visible */ 
body.loading .modal { 
     display: block; 
} 

而且然後最後一點javascript來啓動和停止(隱藏並顯示)加載器:

START:

$(this).addClass("loading"); 

STOP:

$(this).removeClass("loading"); 

來源:http://jsfiddle.net/jonathansampson/VpDUG/170/

相關問題