页面加载期间的 jquery 预加载器
我有一个 OffDiv,里面有加载 gif,如下所示:
<div id="OffDivAndLoadingContainer">
<div id="OffDiv">
</div>
<div id="LoadingContainer">
</div>
</div>
及其 css:
div#OffDivAndLoadingContainer
{
display: none;
position: fixed;
top: 0px;
right: 0px;
z-index: 90000;
width: 100%;
height: 100%;
border: 3px solid green;
}
div#OffDiv
{
width: 100%;
height: 100%;
padding: 0px;
margin: 0px;
background-color: Blue;
filter: alpha(opacity=40); /* internet explorer */
-khtml-opacity: 0.4; /* khtml, old safari */
-moz-opacity: 0.4; /* mozilla, netscape */
opacity: 0.4; /* fx, safari, opera */
border: 1px solid back;
}
div#LoadingContainer
{
background: transparent url('/Images/Loading_Telerik_Vista.gif') no-repeat scroll center center;
position: absolute;
top: 0px;
right: 0px;
width: 100%;
height: 100%;
padding: 0px;
margin: 0px;
border: 1px solid red;
}
我设置了该 OffDiv 的宽度和高度,如下所示:
function OffDivAndLoadingContainerOn() {
var x = screen.availWidth;
//alert(x);
$('div#OffDivAndLoadingContainer').css({ 'width': x });
//alert($('div#OffDivAndLoadingContainer').css('width'));
var y = screen.availHeight;
//alert(y);
$('div#OffDivAndLoadingContainer').css({ 'height': y });
//alert($('div#OffDivAndLoadingContainer').css('height'));
//alert('On');
$('div#OffDivAndLoadingContainer').css({ 'display': 'block' });
}
我想在页面加载开始时向下滑动该 OffDiv,并在页面完全加载时隐藏它!
Q#1:我应该使用哪个 jquery CROSS BROWSER 插件来实现此目的?
Q#2:解决 Q#1 后,我真的想了解百分比预加载器(进度条)在页面加载期间如何工作(我认为使用 jquery 插件更好)?您能给我展示一些演示示例吗?
提前致谢
i have an OffDiv with Loading gif Inside Like Below :
<div id="OffDivAndLoadingContainer">
<div id="OffDiv">
</div>
<div id="LoadingContainer">
</div>
</div>
and their css:
div#OffDivAndLoadingContainer
{
display: none;
position: fixed;
top: 0px;
right: 0px;
z-index: 90000;
width: 100%;
height: 100%;
border: 3px solid green;
}
div#OffDiv
{
width: 100%;
height: 100%;
padding: 0px;
margin: 0px;
background-color: Blue;
filter: alpha(opacity=40); /* internet explorer */
-khtml-opacity: 0.4; /* khtml, old safari */
-moz-opacity: 0.4; /* mozilla, netscape */
opacity: 0.4; /* fx, safari, opera */
border: 1px solid back;
}
div#LoadingContainer
{
background: transparent url('/Images/Loading_Telerik_Vista.gif') no-repeat scroll center center;
position: absolute;
top: 0px;
right: 0px;
width: 100%;
height: 100%;
padding: 0px;
margin: 0px;
border: 1px solid red;
}
i set width and height of that OffDiv Like Below :
function OffDivAndLoadingContainerOn() {
var x = screen.availWidth;
//alert(x);
$('div#OffDivAndLoadingContainer').css({ 'width': x });
//alert($('div#OffDivAndLoadingContainer').css('width'));
var y = screen.availHeight;
//alert(y);
$('div#OffDivAndLoadingContainer').css({ 'height': y });
//alert($('div#OffDivAndLoadingContainer').css('height'));
//alert('On');
$('div#OffDivAndLoadingContainer').css({ 'display': 'block' });
}
i want to slideDown that OffDiv at starting of page load and hide it when the page has been completely loaded!
Q#1 : which jquery CROSS BROWSER plugin should i use for this purpose?
Q#2 : after solving the Q#1 i really want to learn how percentage preloaders (progress bars) work during page load(i think with jquery plugin is better)? would you plz show me some examples with demos?
thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要在 CSS 中显示所有 div,而不是使用上面的代码。
页面加载后,隐藏 div。 (确保您正在加载 jQuery)
这将达到您想要的效果。
建议
这种效果可能会惹恼人们,因为页面加载速度太快,以至于他们必须等待 div 消失。 但是这是一次很好的学习经历。这是另一个效果。而不是删除一个正在加载的div。您认为您可以透露正在加载的页面部分吗?就像谷歌的简单搜索屏幕或苹果的主页所做的那样。
祝你好运。
You'll need to display all of your divs in CSS and not with you code above.
Once the page loads, then hide the div. (make sure you are loading jQuery)
This will have the effect that you desire.
Suggestion
This effect may annoy people because the page will load so fast that they will have to wait of the div to go away. But it is a good learning experience. Here is another effect. Instead of removing a loading div. Do you think you could reveal the parts of the page that you are loading? Like Google's simple search screen did or Apple's homepage did.
Good luck.