css+js 实现遮罩层,禁止按钮触发多次请求

//遮罩背景
function openShadeDiv(){
	var wnd = jQuery(window);
	var doc = jQuery(document);
	var wHeight=0;
	var wWidth=0;
	//当高度少于一屏
    if(wnd.height()>doc.height()){
     	wHeight = wnd.height();
     	wWidth = wnd.width();
    }else{
    	//当高度大于一屏
     	wHeight = doc.height();
     	wWidth = doc.width();
    }
	//创建遮罩背景
	jQuery("body").append("<div id=shadeDiv></div>");
	jQuery("body").find("#shadeDiv")
	    .width(wWidth)
	    .height(wHeight)
	    .css(
	    	{position:"absolute",
	    	top:"0px",left:"0px",
	    	background:"#ccc",
	    	filter:"Alpha(opacity=50);",
	    	opacity:"0.3",zIndex:"9996"
	    	});
}

//遮罩背景
function openLoadingDiv(){
	var strDiv="<div id='loadImgDiv' style='background-color: #ffffe1;z-Index:9997;border:1px solid;border-color: silver;width:120px;position: absolute;left:"+(document.body.clientWidth-120)/2+"px;top:"+(document.body.clientHeight-25)/4+"px'>"+
			"<table align='top'>"+
				"<tr>"+
					"<td style='font-size: 15px;' width=120>"+
						 "<img style='height:22px;width:22px' src='/web/lcam/dmis/include/dutystation/img/blue-loading.gif' /> 数据处理中"+
					"</td>"+
				"</tr>"+
			"</table>"+
		"</div>";

	jQuery("select:enabled").attr("disabled","disabled").attr("removeDisabled","true");
	openShadeDiv();
	jQuery("body").append(strDiv);
	if(jQuery("input[export='true']")!='undefined'&&jQuery("input[export='true']")!=null){
	  jQuery("input[export='true']").attr("disabled","false");
	}
}

//遮罩背景
function closeLoadingDiv(){
	jQuery("select[removeDisabled]").removeAttr("disabled").removeAttr("removeDisabled");
	jQuery("#shadeDiv").remove();
	jQuery("#loadImgDiv").remove();
	if(jQuery("input[export='true']")!='undefined'&&jQuery("input[export='true']")!=null){
	  jQuery("input[export='true']").attr("disabled","");
	}
}
	

猜你喜欢

转载自blog.csdn.net/qq_31806719/article/details/80926333