1. 程式人生 > >網頁提交時新增遮罩層

網頁提交時新增遮罩層

// 表單提交遮罩
$(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()
			});
		});
	}
};

相關推薦

網頁提交新增

// 表單提交遮罩 $(document).ready(function() { $("form").submit(function() { // 新增 GRAYLAYER.create("grayLayer-div"); window.onblur = fu

frameset巢狀的子頁面js彈出新頁面,父頁面新增效果

frameset巢狀的子頁面: 新增遮罩層: $(‘html’, window.parent.document).append(‘<div class=”mtDiv” style=”position: fixed;top: 0%;left: 0%;w

iOS新增

新增遮罩層的原理是在一個可以操作的UIView下面有另一個UIView,下邊的UIView的作用是遮擋住頁面,使其無法進行操作,直到前一個介面的操作結束,然後直接將後一個UIView移除,程式碼如下: [UIView animateWithDuration:0.4 animations

div上新增用於提示資訊

實現重點:背景div設定屬性position: relative;,遮罩層div設定屬性position: absolute;,背景屬性background,屬性bottom: 0;讓遮罩層div在背景div裡面。 <!DOCTYPE html> <html> &l

layui : layer.open載入窗體出現

layer.open載入窗體時出現遮罩層 把窗體方法獨立出來放在layer.use([],function(){});外面,需要的時候從layer.use方法裡面呼叫,就不會出現遮罩層 layer.use([],function(){ $("#新增按鈕id").click(func

ajax同步提交不顯示

業務需求: 上傳資源,由於某種原因必須用到ajax同步去上傳。上傳時耗時較長,為避免使用者再上傳過程中誤操作,需要加遮罩層。 猜到的坑: 正常情況下,如果是非同步是沒有任何問題的。 function upload(){ $("#mask").show();

鼠標hover圖片勻速上升顯示內容top、定位

log 功能 float 相對 body idt ive 子元素 hid 1.html <div class="div1"> <div class="div11"> <p >Dolor nunc vule put

bootstrap 模態框顯示時點選禁止關閉,點選按鈕關閉模態框。

1.頁面載入完成時彈出模態框: 首先要在HTML中新增:aria-hidden="true" data-backdrop="static" $(function(){   $('.modal').mo

表單提交加防重複提交

遮罩層: 增加css樣式: .loadingWrap{ position:fixed; top:0; left:0; width:100%; height:100%; z-index:300; background-

表單提交加和防重複提交

遮罩層:css里加.loadingWrap{ position:fixed; top:0; left:0; width:100%; height:100%;

重複提交,加

function ajaxLoading(msg,msgMaginTop){ //資訊提示 var default_msg = '正在處理,請稍後。。。'; //資訊佈局位置向上內邊距 var default_msgMaginTop= -45; var _msg

解決bootstrap提交後進行全域性重新整理導致的仍然存在的問題

首先,宣告,本人轉載自http://blog.csdn.net/murphy_wnag/article/details/66478346在此,非常感謝MURPHY_WNAG的文章對我問題的解決給與了很大幫助下面是我自己的一些看法:遮罩層存在的原因確實是由於存在一個modal-

如何顯示禁止底層頁面滑動

個人github:https://github.com/qiilee  歡迎follow 在touchmove時禁用瀏覽器預設事件, document.addEventListener('touc

移動端 滑動表層div禁止底層div滑動 就是

在遮罩層新增 @touchmove.prevent 用法 <div v-show="ishow" class="fiex" @touchmove.prevent> <div @click="hide" class="hide"></div

自己寫的一個按鈕控制元件,點選在介面出現一個loading

Imports System.Collections.Generic Imports System.ComponentModel Imports System.Text Imports System.Web Imports System.Web.UI Imports Syst

自寫jQuery插件,實現簡單網頁/彈出功能,兼容IE6、IE7

left 文章 int 灰色 click absolute tro maxwidth 站點 版權聲明:本文為博主原創文章,未經博主同意不得轉載。 https://blog.csdn.net

Winform應用程序實現通用

圖片 ted containe completed ini spa mst per 動圖 Winform應用程序實現通用遮罩層 在WEB上,我們在需要進行大數據或復雜邏輯處理時,由於耗時較長,一般我們會在處理過程中的頁面上顯示一個半透明的遮罩層,上面放個圖標或提示:

Winform應用程序實現通用

添加 str img 控件 text 邏輯 mar chang sha 之前先後發表過:《Winform應用程序實現通用遮罩層》、《Winform應用程序實現通用消息窗口》,這兩款遮罩層其實都是基於彈出窗口的,今天為大家分享一個比較簡單但界面相對友好的另一種實現方案,廢話不

JS+CSS簡單實現DIV顯示隱藏【轉藏】

button left dtd -m javascrip htm width dex absolute <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/

小特效

cti wid bsp z-index log pos absolute 登錄 reat 今天學了一個遮罩層的特效,主要用在網頁裏面註冊頁面和登陸頁面的使用:     <style>     * {     margin: 0px;