【发布时间】:2013-09-24 12:41:38
【问题描述】:
我想在我的页面加载like here 时在我的页面中显示一个正在运行的进度条。 我在示例中使用了一个简单的加载图像,但我想将其转换为运行进度条。这是我的代码:
$(window).load(function() {
alert("hi");
$('#loading').hide();
});
#loading {
width: 100%;
height: 100%;
top: 0px;
left: 0px;
position: fixed;
display: block;
opacity: 0.7;
background-color: #fff;
z-index: 99;
text-align: center;
}
#loading-image {
position: absolute;
top: 100px;
left: 240px;
z-index: 100;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js"></script>
<div id="loading">
<img id="loading-image" src="http://cdn.nirmaltv.com/images/generatorphp-thumb.gif" alt="Loading..." />
</div>
<div id="txt">
<h2>Let AJAX change this text</h2>
</div>
<button>Change Content</button>
这是JSFiddle
【问题讨论】:
-
是什么让您的网站加载了 50%?
-
这只是一个例子,我想在页面开始加载时显示一个从 1% 开始的进度条,并在加载完成后上升到 100%。
-
查看pace.js
-
同意@Mottie - 我的项目也使用github.hubspot.com/pace/docs/welcome。这是一个非常好的插件,而且它也是自动的,这意味着您所要做的就是包含脚本。
标签: javascript jquery css html5-canvas