这篇文章介绍了Javascript 遮罩层和加载效果代码
有需要的朋友可以参考一下
复制代码 代码如下:
//loading
function showLoad(tipInfo) {
var iWidth = ; //弹出窗口的宽度;
var iHeight = ; //弹出窗口的高度;
var scrolltop = ;
var scrollleft = ;
var cheight = ;
var cwidth = ;
var eTip = documentcreateElement(div);
eTipsetAttribute(id tipDiv);
eTipstyleposition = absolute;
eTipstyledisplay = none;
eTipstyleborder = solid px #DDD;
eTipstylebackgroundColor = #BD;
eTipstylepadding = px px;
if(documentbodyscrollTop){//这是一个js的兼容
scrollleft=documentbodyscrollLeft;
scrolltop=documentbodyscrollTop;
cheight=documentbodyclientHeight;
cwidth=documentbodyclientWidth;
}
else{
scrollleft=documentdocumentElementscrollLeft;
scrolltop=documentdocumentElementscrollTop;
cheight=documentdocumentElementclientHeight;
cwidth=documentdocumentElementclientWidth;
}
iHeight = eTipoffsetHeight;
var v_left=(cwidthiWidth)/ + scrollleft; //
var v_top=(cheightiHeight)/+ scrolltop;
eTipstyleleft = v_left + px;
eTipstyletop = v_top + px;
eTipinnerHTML = <img src=Images/loadinggif style=float:left; /><span style=color:#ffffff; fontsize:px> + tipInfo + </span>;
try {
documentbodyappendChild(eTip);
} catch (e) { }
$("#tipDiv")css("float" "right");
$("#tipDiv")css("zindex" "");
$(#tipDiv)show();
ShowMark();
}
function closeLoad() {
$(#tipDiv)hide();
HideMark();
}
//显示蒙灰层
function ShowMark() {
var xp_mark = documentgetElementById("xp_mark");
if (xp_mark != null) {
//设置DIV
xp_markstyleleft = + "px";
xp_markstyletop = + "px";
xp_markstyleposition = "absolute";
xp_markstylebackgroundColor = "#";
xp_markstylezIndex = "";
if (documentall) {
xp_markstylefilter = "alpha(opacity=)";
var Ie_ver = navigator["appVersion"]substr( );
if (Ie_ver == || Ie_ver == ) { hideSelectBoxes(); }
}
else { xp_markstyleopacity = ""; }
xp_markstylewidth = "%";
xp_markstyleheight = "%";
xp_markstyledisplay = "block";
}
else {
//页面添加div explainDiv注意必须是紧跟body 内的第一个元素否则IE不正常
$("body")prepend("<div id=xp_mark style=display:none;></div>");
ShowMark(); //继续回调自己
}
}
//隐藏蒙灰层
function HideMark() {
var xp_mark = documentgetElementById("xp_mark");
xp_markstyledisplay = "none";
var Ie_ver = navigator["appVersion"]substr( );
if (Ie_ver == || Ie_ver == ) { showSelectBoxes(); }
}