天天躁日日躁狠狠躁AV麻豆-天天躁人人躁人人躁狂躁-天天澡夜夜澡人人澡-天天影视香色欲综合网-国产成人女人在线视频观看-国产成人女人视频在线观看

jquery 鎖定彈出層實現代碼

基于jquery的鎖定彈出層
這個東西也是隨手總結出來的,引用了一些js框架jquery的方法。
div遮蓋其他控件的方法參考了 對于需要遮蓋flash的,請將flash控件的WMode變量值設置為Transparent
使用方法:
復制代碼 代碼如下:
<script src="jquery.js"></script>
<script src="effect/maskDiv.js"></script>
<script>

//配置模塊
var moduleEvent = [{"idName":"close" , "eventName":"click" , "doMethod":"CLOSE_DIV"},{"idObj":window,"eventName":"resize" , "doMethod":"RESIZE_WINDOW"}];
qihoo_effect_maskDiv.showMaskDiv("your div id" , moduleEvent); //請把div的display設置為none。
*******************************************************
effect/maskDiv.js
復制代碼 代碼如下:
var qihoo_effect_maskDiv = {
_module : {},
_css : {},
_instance : "" ,
_event : {"CLOSE_WINDOW" : function() { window.close(); } , "CLOSE_DIV" : function(){qihoo_effect_maskDiv.closeDiv();} , "RESIZE_WINDOW" : function(){qihoo_effect_maskDiv.resizeWindow();} },
_isIe : eval("false;/*@cc_on@if(@/x5fwin32)isMSIE=true@end@*/") ,
init : function (){
if (this._instance){
return this._instance;
}
this.appendBackGroundDiv();
this._instance = this;
return this._instance;
},
appendBackGroundDiv : function (){
this._module.backGroundDiv = $("<div id='qihoo_effect_maskDiv_module_backGroundDiv'></div>");
this._module.backGroundDiv.appendTo("body");
this._css.mask = { "background-color":"#000" , "position":"absolute", "-moz-opacity": "0.75" , "filter":"alpha(opacity=75)","z-index":5 , "width" : document.body.clientWidth+100 , "height" : document.body.clientHeight+300 , "top" : "0px" , "left":"0px" , "display" : "none"};
this._module.backGroundDiv.css(this._css.mask);
this._module.coverIframe = $("<iframe src='Javascript:false' id='qihoo_effect_maskDiv_module_iframe' frameborder='1'></iframe>");
this._css.normalIframe = {'position':'absolute','left':'-1000px','top':'-1000px','z-index':7};
this._module.coverIframe.css(this._css.normalIframe);
this._module.coverIframe.appendTo("body");
},
showMaskDiv : function (showDivId , moduleEvent, position ){
instance = this;
if (this._isIe){
if(document.readyState != "complete"){
setTimeout(function(){instance.showMaskDiv(showDivId , moduleEvent , position);} , 100);
return false;
}
}
if ("" == this._instance){
this.init();
}
this._module.showDiv = $("#"+showDivId);
if (typeof position == 'undefined'){
this._css.coverIframe = {'position':'absolute','top':parseInt(screen.height/4+document.documentElement.scrollTop)+"px",'left':parseInt(screen.width/4+document.documentElement.scrollLeft)+"px",'zIndex':7};
this._css.coverd = {"zIndex" : 10 , "position" : "absolute" ,"width":"400px" , "height":"240px" ,"top": parseInt(screen.height/4+document.documentElement.scrollTop)+"px", "left":parseInt(screen.width/4+document.documentElement.scrollLeft)+"px"};
}
else{
this._css.coverIframe = {'position':'absolute',"height" : position.height, "width":position.width , "top": position.top , "left":position.left,'zIndex':7};
this._css.coverd = {"zIndex" : 10 , "position" : "absolute" , "height" : position.height, "width":position.width , "top": position.top , "left":position.left};
}
for (var i in moduleEvent){
if (typeof moduleEvent[i].idName != "undefined") {
$("#"+moduleEvent[i].idName).bind(moduleEvent[i].eventName , this._event[moduleEvent[i].doMethod]);
}
if (typeof moduleEvent[i].idObj != "undefined") {
$(moduleEvent[i].idObj).bind(moduleEvent[i].eventName , this._event[moduleEvent[i].doMethod]);
}
}
this._module.backGroundDiv.show();
showDivFront = this._module.showDiv;
cssParam = this._css;
coveredIframe = this._module.coverIframe;
this._module.backGroundDiv.animate({opacity:0.75},"normal" , function(){coveredIframe.css(cssParam.coverIframe);showDivFront.show();});
this._module.showDiv.css(this._css.coverd);
},
resizeWindow : function (){
this._css.mask = { "background-color":"#000" , "position":"absolute", "-moz-opacity": "0.75" , "opacity":"0.75" , "filter":"alpha(opacity=75)","zIndex":5 , "width" : document.body.clientWidth+100, "height" : document.body.clientHeight+300 , "top" : "0px" , "left":"0px"};
this._module.backGroundDiv.css(this._css.mask);
},
closeDiv : function (){
this._module.coverIframe.css(this._css.normalIframe);
this._module.showDiv.hide();
hidebBackGroundDiv = this._module.backGroundDiv;
this._module.backGroundDiv.animate({opacity:0},"normal", function(){hidebBackGroundDiv.hide();});
}
};

看評論所言,加了一點用法:

這里是一個不引入jquery框架的實現同樣效果的程序。

引入文件
<script src="/js/jquery.js"></script>
<script src="/js/maskDiv.js"></script>
配置事件
<script>
var moduleEvent = [
{"idName":"closeForm" , "eventName":"click" , "doMethod":"CLOSE_DIV"},
{"idObj":window,"eventName":"resize" , "doMethod":"RESIZE_WINDOW"}
];
</script>
注:idName是綁定事件的html組件的id,idObj是html控件變量
配置初始位置(可選步驟)
<script>
var position = {"width":"300px", "height":"400px" , "top":"300px", "left":"720px"};
</script> 顯示遮罩層
qihoo_effect_maskDiv.showMaskDiv(divId, moduleEvent , position);或者qihoo_effect_maskDiv.showMaskDiv(divId, moduleEvent );
隱去遮罩層
qihoo_effect_maskDiv.closeDiv();

js實現的遮蓋層的定義:
經常遇到要彈出一個懸浮層,鼠標的事件只能在本層上有效,底層會失效。能用的做 法是在懸浮層和底層之間在加一個遮蓋層,遮蓋住整個瀏覽器,這樣就不能點擊底層的任何東西了。
復制代碼 代碼如下:
var w = Math.max(document.documentElement.scrollWidth, document.documentElement.clientWidth) + "px"; //獲取寬
var h = Math.max(document.documentElement.scrollHeight, document.documentElement.clientHeight) + "px"; //獲取高
//定義一個透明背景層
var gb = $("<div/>").attr("id","gb")
.css({top:"0",left:"0",zIndex:"2",position:"absolute",filter:"alpha(opacity=0)",background:"#fff"})
.css("width",w).css("height",h)

其實說明最主要還是說明一下背景層的CSS定義。首先要使top和left有效,就要設置 position:absolute。filter:"alpha(opacity=0)設置透明度,數值0-100,0表示完全透明,100表示不透明。background設置背景層的顏色。zIndex的值只要比底層的高,比彈出層的低就行了。(zIndex的值越大表示越在上層)。好了,基本就是這樣吧!

JavaScript技術jquery 鎖定彈出層實現代碼,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 厨房玩朋友娇妻中文字幕 | 日本色高清 | 亚洲精品中文字幕一二三四区 | 久久re这里视频精品8 | 韩剧19禁啪啪无遮挡大尺度 | 18禁黄久久久AAA片 | 村妇偷人内射高潮迭起 | 免费看a毛片 | 秋霞电影在线观看午夜伦 | 国产激情视频在线播放 | 88蜜桃人妻无码精品系列 | 97公开超碰在线视频 | 男人私gay挠脚心vk视频 | 伦理片 a在线线版韩国 | 理论片午午伦夜理片久久 | 九九精品久久 | 青青青青青青青草 | 日日噜噜噜夜夜爽爽狠狠 | 厨房玩朋友娇妻中文字幕 | 99国内精品 | MM131亚洲精品久久安然 | 欧美午夜精品一区二区蜜桃 | 在线 | 果冻国产传媒61国产免费 | 亚洲AV色香蕉一区二区9255 | 神马电影院午夜神福利在线观看 | 日日干夜夜爽 | 亚洲人成7777 | 久久精品国产eeuss | 被送到黑人性奴俱乐部 | 成年视频xxxxxx在线 | 久热人人综合人人九九精品视频 | 柠檬福利精品视频导航 | 久久国产精品免费A片蜜芽 久久国产精品萌白酱免费 久久国产精品麻豆AV影视 | 免费乱理伦片在线观看八戒 | 国产日韩久久久精品影院首页 | 亚洲国产系列一区二区三区 | 精品一区二区三区高清免费观看 | 久久偷拍vs国产在线播放 | 日本边添边摸边做边爱边 | 国产成人综合视频 | 把手戳进美女尿口里动态图 |