查看: 5618|回复: 0
打印 上一主题 下一主题

非常漂亮的loading效果网页代码

[复制链接]
跳转到指定楼层
1#
发表于 2008-10-25 23:32:20 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
台州网址导航
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>爱问CPU</title>
</head>

<BODY STYLE="FONT-SIZE: 10pt; FONT-FAMILY: Verdana, Arial, Helvetica">

<SCRIPT LANGUAGE="JScript">

var NUMBER_OF_REPETITIONS = 40;
var nRepetitions = 0;
var g_oTimer = null;

function startLongProcess()
{
   divProgressDialog.style.display = "";
   resizeModal();
   btnCancel.focus();

   // Add a resize handler for the window
   window.onresize = resizeModal;

   // Add a warning in case anyone tries to navigate away or refresh the page
   window.onbeforeunload = showWarning;

   //
   // Here's where you would normally kick off a long asynchronous process
   // like a file download or a remote database operation. Here, we use
   // our "long process" to simulate this process.
   //

   continueLongProcess();
}

function updateProgress(nNewPercent)
{
   // Update our pseudo progress bar
   divProgressInner.style.width = (parseInt(divProgressOuter.style.width)  
      * nNewPercent / 100)+ "px";
}

function stopLongProcess()
{
   if (g_oTimer != null)
   {
      // Clear the timer so we don't get called back an extra time
      window.clearTimeout(g_oTimer);
      g_oTimer = null;
   }

   // Hide the fake modal DIV
   divModal.style.width = "0px";
   divModal.style.height = "0px";
   divProgressDialog.style.display = "none";

   // Remove our event handlers
   window.onresize = null;
   window.onbeforeunload = null;

   nRepetitions = 0;
}

function continueLongProcess()
{
   if (nRepetitions < NUMBER_OF_REPETITIONS)
   {
      // Set the timeout somewhere between 0 and .25 seconds
      var nTimeoutLength = Math.random() * 250;
      updateProgress(100 * nRepetitions / NUMBER_OF_REPETITIONS);

      g_oTimer = window.setTimeout("continueLongProcess();", nTimeoutLength);
      nRepetitions++;
   }
   else
   {
      stopLongProcess();
   }
}

function showWarning()
{
   //Warn users before they refresh the page or navigate away
   return "Navigating to a different page or refreshing the window could cause you to lose precious data.nnAre you*absolutely* certain you want to do this?";
}

function resizeModal()
{
   // Resize the DIV which fakes the modality of the dialog DIV
   divModal.style.width = document.body.scrollWidth;
   divModal.style.height = document.body.scrollHeight;

   // Re-center the dialog DIV
   divProgressDialog.style.left = ((document.body.offsetWidth -  
divProgressDialog.offsetWidth) / 2);
   divProgressDialog.style.top = ((document.body.offsetHeight -  
divProgressDialog.offsetHeight) / 2);
}

</SCRIPT>

<INPUT TYPE="BUTTON" VALUE="Click Me!" onclick="startLongProcess();">

<!-- BEGIN PROGRESS DIALOG -->
<div STYLE="BORDER: buttonhighlight 2px outset; FONT-SIZE: 8pt; Z-INDEX:  
4; FONT-FAMILY: Tahoma; POSITION: absolute; BACKGROUND-COLOR: buttonface;  
DISPLAY: none; WIDTH: 350px; CURSOR: default" ID="divProgressDialog"  
onselectstart="window.event.returnValue=false;">
   <div STYLE="PADDING: 3px; FONT-WEIGHT: bolder; COLOR: captiontext;  
BORDER-BOTTOM: white 2px groove; BACKGROUND-COLOR: activecaption">
      Downloading Requested Document
   </div>
   <div STYLE="PADDING: 5px">
      Please wait while I download the document you requested.
   </div>
   <div STYLE="PADDING: 5px">
      This may take several seconds.
   </div>
   <div STYLE="PADDING: 5px">
         <div ID="divProgressOuter" STYLE="BORDER: 1px solid threedshadow;  
WIDTH: 336px; HEIGHT: 15px">
            <div ID="divProgressInner" STYLE="COLOR: white; TEXT-ALIGN:  
center; BACKGROUND-COLOR: infobackground; MARGIN: 0px; WIDTH: 0px; HEIGHT:  
13px;"></div>
         </div>
   </div>
   <div STYLE="BORDER-TOP: white 2px groove; PADDING-BOTTOM: 5px; PADDING-TOP: 3px;  
BACKGROUND-COLOR: buttonface; TEXT-ALIGN: center">
         <INPUT STYLE="FONT-FAMILY: Tahoma; FONT-SIZE: 8pt" TYPE="button"  
ID="btnCancel" onclick="stopLongProcess();" VALUE="Cancel">
   </div>
</div>
<!-- END PROGRESS DIALOG -->

<!-- BEGIN FAKE MODAL DIV-->
<div ID="divModal"
   STYLE="BACKGROUND-COLOR: white; FILTER: alpha(opacity=75); LEFT: 0px; POSITION:
absolute; TOP: 0px; Z-INDEX: 3"
   onclick="window.event.cancelBubble=true; window.event.returnValue=false;">
</div>
<!-- END FAKE MODAL DIV -->
</body>
</html>
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 转播转播 分享分享 分享淘帖
台州维博网络(www.tzweb.com)专门运用PHP+MYSQL/ASP.NET+MSSQL技术开发网站门户平台系统等。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

网站推广
关于我们
  • 台州朗动科技(Tzweb.com)拥有多年开发网站平台系统门户手机客户端等业务的成功经验。主要从事:政企网站,系统平台,微信公众号,各类小程序,手机APP客户端,浙里办微应用,浙政钉微应用、主机域名、虚拟空间、后期维护等服务,满足不同企业公司的需求,是台州地区领先的网络技术服务商!

Hi,扫描关注我

Copyright © 2005-2026 站长论坛 All rights reserved

Powered by 站长论坛 with TZWEB Update Techonolgy Support

快速回复 返回顶部 返回列表