js實現 【正在載入,請稍後….】 功能

來源:互聯網
上載者:User

做IM的時候,從Message Service器擷取使用者回應時間比較慢,這個時候,顯示一下動態提示效果,使用者會感覺安心些。

 

先發個效果,

還不會做gif動態圖,實際效果應該可以想到吧。。。。

 

好了,發源碼

 

<div id="lockScreen"><form name=loading><td align=center><p><font color=gray>正在載入,請稍候.......</font></p><p><input type=text name=chart size=46style="font-family:Arial; font-weight:bolder; color:gray;background-color:white; padding:0px; border-style:none;"><br> <input type=text name=percent size=46style="font-family:Arial; color:gray; text-align:center; border-width:medium; border-style:none;"><script>var bar = 0;var line = "||";var amount = "||";count();function count() {bar = bar + 2;amount = amount + line;document.loading.chart.value = amount;document.loading.percent.value = bar + "%";if (bar < 99) {setTimeout("count()", 80);} else {hideScreen();}}</script></p></td></form></div><div id="Screen" style="width: auto;"><div id="roster" class="roster"></div></div>

兩個地區,id分別為lockScreen和Screen,開始時候顯示lockScreen,之後載入完畢顯示Sreen內容。

 

// lockScreen dml@2012.9.7function hideScreen() {var Element = document.getElementById('lockScreen');var Elements = document.getElementById('Screen');Element.style.display = 'none';Elements.style.display = '';}

 

這個只是實現簡單的功能,載入條的時間也是估算的,需要最佳化的地方還很多。有空再弄弄。。。。

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.