// 表单提交遮罩
$(document).ready(function() {
$("form").submit(function() {
// 添加
GRAYLAYER.create("grayLayer-div");
window.onblur = function() {
// 删除
GRAYLAYER.del("grayLayer-div");
};
});
});
// aiax提交遮罩
$.ajaxSetup({
cache : false,
type : "POST",
beforeSend : function(xhr) {
// 添加
GRAYLAYER.create("grayLayer-div");
},
complete : function(xhr, status) {
// 删除
GRAYLAYER.del("grayLayer-div");
},
success : function(data, textStatus) {
// 删除
GRAYLAYER.del("grayLayer-div");
},
error : function(xhr, status, e) {
// 删除
GRAYLAYER.del("grayLayer-div");
}
});
var GRAYLAYER = {
create : function(className) {
var _grayLayer = document.createElement("div");
_grayLayer.className = className;
_grayLayer.style.cssText = "display:block;position: absolute;top: 0px;left: 0px;background: #0000;opacity: 0.3;filter: alpha(opacity=50);z-index: 999;";
_grayLayer.style.width = $(document).width() + 'px';
_grayLayer.style.height = $(document).height() + 'px';
document.body.appendChild(_grayLayer);
this.resize(className);
setTimeout("GRAYLAYER.del('grayLayer-div');", 5000);
},
del : function(className) {
$("." + className).remove();
},
resize : function(className) {
$(window).resize(function() {
$("." + className).css({
"width" : $(document).width(),
"height" : $(document).height()
});
});
}
};
网页提交时添加遮罩层
最新推荐文章于 2020-05-11 10:46:34 发布