博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Jquery页面加载效果
阅读量:4507 次
发布时间:2019-06-08

本文共 2781 字,大约阅读时间需要 9 分钟。

 

 

1、说明

  Jquery页面加载可实现异步请求时提示“请稍后,正在加载...”效果,同步请求不可用(即ajax async: false)。本文地址:

2、代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<!DOCTYPE html PUBLIC 
"-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
>
<html xmlns=
"http://www.w3.org/1999/xhtml"
>
<head>
    
<meta http-equiv=
"Content-Type" 
content=
"text/html; charset=utf-8" 
/>
    
<title>jquery页面加载特效</title>
    
<style type=
"text/css"
>
        
*
        
{
            
margin: 0;
            
padding: 0;
            
list-style-type: none;
        
}
        
a, img
        
{
            
border: 0;
        
}
        
.loading
        
{
            
margin: 100px auto 0 auto;
            
width: 400px;
            
text-align: center;
            
font-size: 18px;
        
}
        
.loading .action
        
{
            
text-decoration: none;
            
font-family: 
"微软雅黑" 
"宋体"
;
        
}
         
        
.cover
        
{
            
position: 
fixed
;
            
top: 0;
            
right: 0;
            
bottom: 0;
            
left: 0;
            
z-index: 998;
            
width: 100%;
            
height: 100%;
            
_padding: 0 20px 0 0;
            
background: #f6f4f5;
            
display: none;
        
}
        
.showLoad
        
{
            
position: 
fixed
;
            
top: 0;
            
left: 50%;
            
z-index: 9999;
            
opacity: 0;
            
filter: alpha(opacity=0);
            
margin-left: -80px;
        
}
        
*html, *html body
        
{
            
background-image: url(about:blank);
            
background-attachment: 
fixed
;
        
}
        
*html .showLoad, *html .cover
        
{
            
position: absolute;
            
top: expression(eval(document.documentElement.scrollTop));
        
}
        
#ajaxLoad
        
{
            
border: 1px solid #8CBEDA;
            
font-size: 12px;
            
font-weight: bold;
        
}
        
#ajaxLoad div.loadAll
        
{
            
width: 180px;
            
height: 50px;
            
line-height: 50px;
            
border: 2px solid #D6E7F2;
            
background: #fff;
        
}
        
#ajaxLoad img
        
{
            
margin: 10px 15px;
            
float
: left;
            
display: inline;
        
}
    
</style>
    
<script type=
"text/javascript" 
src=
"js/jquery.min.js"
></script>
    
<script type=
"text/javascript"
>
        
$(function () {
            
var 
hei = $(document).height();
            
$(
".cover"
).css({ 
"height"
: hei });
            
$(
".action"
).click(function () {
                
startWaiting();
                
setTimeout(function () {
                    
endWaiting();
                
}, 3000);
            
});
        
});
 
        
//开始加载
        
function startWaiting() {
            
$(
".cover"
).css({ 
'display'
'block'
'opacity'
'0.8' 
});
            
$(
".showLoad"
).stop(
true
).animate({ 
'margin-top'
'300px'
'opacity'
'1' 
}, 200);
        
}
 
        
//结束加载
        
function endWaiting() {
            
$(
".showLoad"
).stop(
true
).animate({ 
'margin-top'
'250px'
'opacity'
'0' 
}, 400);
            
$(
".cover"
).css({ 
'display'
'none'
'opacity'
'0' 
});
        
}
 
    
</script>
</head>
<body>
    
<div 
class
=
"loading"
>
        
<a 
class
=
"action" 
href=
"javascript:void(0);"
>点击加载特效</a></div>
    
<div 
class
=
"cover"
>
    
</div>
    
<div id=
"ajaxLoad" 
class
=
"showLoad"
>
        
<div 
class
=
"loadAll"
>
            
<img src=
"image/waiting.gif"
>加载中,请稍候...</div>
    
</div>
</body>
</html>

3、DEMO

  

 

 转 

转载于:https://www.cnblogs.com/wenJiaQi/p/6426295.html

你可能感兴趣的文章
C++底层数据结构实现
查看>>
Python学习(二)
查看>>
如何提高Linq查询的性能(上)
查看>>
敏捷开发相关编辑思想(SOA、DDD、REST、CQRS)
查看>>
Qt中mysql编译出错问题
查看>>
resin3服务器resin.conf文件的配置
查看>>
ubuntu下codeblocks编译出现libxxx.so needed by xxx.so not found
查看>>
effective C++ 条款 40:明智而审慎地使用多重继承
查看>>
三维渲染引擎设计与实践(五)
查看>>
20154313 刘文亨 EXP9
查看>>
快速排序
查看>>
Solidity的三种转账方式与比较
查看>>
js api 之 fetch、querySelector、form、atob及btoa
查看>>
php json_encode
查看>>
Docker系统四:Dcoker的镜像管理
查看>>
C#多线程---Semaphore实现线程同步
查看>>
.Net统计代码执行时间
查看>>
PHP连接MySQL报错:Fatal error: Call to undefined function mysql_connect()之解决方法
查看>>
postgre 二进制存储
查看>>
字符串kmp&exkmp&马拉车(刷题总结)
查看>>