网页提交时添加遮罩层

来源:互联网 发布:高圆圆整了哪里 知乎 编辑:程序博客网 时间:2024/05/24 05:22
// 表单提交遮罩$(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()});});}};

0 0
原创粉丝点击