Pops.js
2.18 KB
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
function showPageloading(addressImg, img_w, img_h,background) {
//得到页面高度
var h = (document.documentElement.scrollHeight > document.documentElement.clientHeight) ? document.documentElement.scrollHeight : document.documentElement.clientHeight;
//得到页面宽度
var w = (document.documentElement.scrollWidth > document.documentElement.clientWidth) ? document.documentElement.scrollWidth : document.documentElement.scrollWidth;
var procbg = document.createElement("div"); //首先创建一个div
procbg.setAttribute("id", "mybg"); //定义该div的id
if (typeof (background) != "undefined" && background != "") {
procbg.style.background = background;
} else {
procbg.style.background = "#555";
}
procbg.style.width = "100%";
procbg.style.height = "100%";
procbg.style.position = "fixed";
procbg.style.top = "0";
procbg.style.left = "0";
procbg.style.zIndex = "10000";
//procbg.style.opacity = "0.6";
procbg.style.filter = "Alpha(opacity=70)";
//取消滚动条
document.body.appendChild(procbg);
document.body.style.overflow = "auto";
var pimg = document.createElement("img"); //创建一个img
pimg.setAttribute("id", "bg_img"); //定义该div的id
pimg.setAttribute("src", addressImg); //定义该div的id
var img_w1 = (w - img_w) / 2;
var img_h1 = (h - img_h) / 2;
pimg.style.top = img_h1 + "px";
pimg.style.left = img_w1 + "px";
pimg.style.position = "fixed";
pimg.style.opacity = "0.9";
document.getElementById("mybg").appendChild(pimg);
var element = document.createElement("div");
element.style.top = (parseInt(img_h1) + parseInt(img_h)+(5)) + "px";
element.style.left = (w - 100)/2 + "px";
element.style.position = "fixed";
element.className="lbsFont";
var textNode = document.createTextNode("正在努力加载中...");
element.appendChild(textNode);
document.getElementById("mybg").appendChild(element);
}
function closePageloading(){ //关闭弹出层
var mybg = document.getElementById("mybg");
document.body.removeChild(mybg);
document.body.style.overflow = "auto";//恢复页面滚动条
}