js鎖屏解屏通過(guò)對(duì)$.ajax進(jìn)行封裝實(shí)現(xiàn)
更新時(shí)間:2014年07月31日 09:30:39 投稿:whsnow
js鎖屏解屏是通過(guò)對(duì)$.ajax進(jìn)行封裝實(shí)現(xiàn)的,需要的朋友可以參考下
jquery插件源碼:
/** * 對(duì)jquery中$.ajax進(jìn)行封裝,以便加入鎖屏功能 * isAsync 是否為異步請(qǐng)求,默認(rèn)為true * isLock 是否鎖屏,默認(rèn)是true * isCache 是否從瀏覽器緩存中加載信息,默認(rèn)是fasle ***/ ;(function($) { $.fn.doPost = function(settings) { settings = jQuery.extend({ isAsync:true, type : "post", url : null, dataType : null, data : null, success : null, error : toError, isLock : true, isCache : false }, settings); $(this).each(function(){ if(settings.isLock){ lockSrc(); } $.ajax({ async:settings.isAsync, type:settings.type, url:settings.url, dataType:settings.dataType, data:settings.data, cache:settings.isCache, success:function(msg){ if(settings.isLock){ unlockSrc(); } settings.success(msg); }, error:settings.error }); }); //鎖屏方法 function lockSrc(){ $(".lockDiv").css({"opacity":"0.5"}).fadeIn('normal'); var scrollWidth = document.documentElement.clientWidth;//document.body.clientWidth; var scrollHeight =document.documentElement.clientHeight; // document.body.clientHeight; var divWidth = $(".lockDivInfo").width(); var divHeight = $(".lockDivInfo").height(); var divLeft = scrollWidth/2-divWidth/2; var divTop = scrollHeight/2-divHeight/2; //console.log("bodyWidth="+scrollWidth+",bodyHeight="+scrollHeight+",divHeight="+divHeight+",divWidth="+divWidth+",left="+divLeft+",top="+divTop); $(".lockDivInfo").css({"position":"absolute","top":divTop,"left":divLeft}).fadeIn('normal'); } //解屏方法 function unlockSrc(){ $(".lockDivInfo").fadeOut('normal'); $(".lockDiv").fadeOut('normal'); } function toError(){ alert("操作失敗!"); } }; })(jQuery);
鎖屏樣式:
/* 鎖屏 */ .lockDiv { width: 100%; height: 100%; display: none; z-index: 10; background-color: #DFE8F6; position: absolute; top: 0px; left: 0px; } .lockDivInfo { width: 50px; height: 2px; display: none; position: absolute; left: 0px; top: 0px; z-index: 11 } #CloseDiv { float: right; width: 100px; height: 100px; margin-top: 10px; margin-right: 10px; }
<div class="lockDiv"></div> <div class="lockDivInfo" > <img id="CloseDiv" src="/hnhd/images/circle_animation.gif"></img> </div>
使用方法
//查詢 $("#queryBtn").click(function(){ selecCheckByRegionApp.query(); }); var selecCheckByRegionApp={}; selecCheckByRegionApp.query=function(){ var settion={ type:"post", url: 'selfCheckStatisticAction!findByRegion' , dataType:"text", data:$("#searchForm").formSerialize(), success:function(msg){ $("#contentDiv").html(msg); } }; $("#queryBtn").doPost(settion); }
相關(guān)文章
JavaScript獲取客戶端計(jì)算機(jī)硬件及系統(tǒng)等信息的方法
本文為大家詳細(xì)介紹下如何使用JavaScript獲取客戶端計(jì)算機(jī)硬件及系統(tǒng)等信息,下面有個(gè)不錯(cuò)的示例,感興趣的朋友可以參考下2014-01-01簡(jiǎn)述JS中forEach()、map()、every()、some()和filter()的用法
JS中常常需要對(duì)數(shù)組進(jìn)行遍歷、迭代操作,而我們常用的就是for語(yǔ)句對(duì)數(shù)組進(jìn)行迭代,下面這篇文章主要給大家介紹了關(guān)于JS中forEach()、map()、every()、some()和filter()的用法,需要的朋友可以參考下2022-05-05Javascript優(yōu)化技巧之短路表達(dá)式詳細(xì)介紹
這篇文章主要介紹了Javascript優(yōu)化技巧之短路表達(dá)式詳細(xì)介紹,本文講解了什么是短路表達(dá)式,并給出了一些示例,需要的朋友可以參考下2015-03-03原生js+canvas實(shí)現(xiàn)驗(yàn)證碼
這篇文章主要為大家詳細(xì)介紹了原生js+canvas實(shí)現(xiàn)驗(yàn)證碼,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2020-11-11uni-app小程序?qū)崿F(xiàn)微信在線聊天功能(私聊/群聊)
這篇文章主要介紹了uni-app小程序?qū)崿F(xiàn)微信在線聊天(私聊/群聊),今天記錄一下項(xiàng)目核心功能的實(shí)現(xiàn)過(guò)程。頁(yè)面UI以及功能邏輯全部來(lái)源于微信,即時(shí)聊天業(yè)務(wù)的實(shí)現(xiàn)使用socket.io,前端使用uni-app開(kāi)發(fā),后端服務(wù)器基于node實(shí)現(xiàn),數(shù)據(jù)庫(kù)選擇mongoDB,需要的朋友可以參考下2023-02-02Ajax跨域?qū)崿F(xiàn)代碼(后臺(tái)jsp)
這篇文章主要介紹了Ajax跨域?qū)崿F(xiàn)代碼(后臺(tái)jsp),需要的朋友可以參考下2017-01-01一問(wèn)了解JavaScript中的元數(shù)據(jù)
本文主要介紹了一問(wèn)了解JavaScript中的元數(shù)據(jù),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2023-04-04