JavaScript 遮罩
来源:互联网 发布:精仿魔客吧整站源码 编辑:程序博客网 时间:2024/05/16 08:07
//窗口的宽度和高度
function Dimensions(){
var windowWidth = window.innerWidth;
var windowHeight = window.innerHeight;
if(windowWidth){
winWidth = windowWidth
}else if((document.body) && (document.body.clientWidth)){
winWidth = document.body.clientWidth;
}
if(windowHeight){
winHeight = windowHeight;
}else if(document.body && document.body.clientHeight){
winHeight = document.body.clientHeight;
}
var documentElement = document.documentElement;
if(documentElement && documentElement.clientWidth && documentElement.clientHeight){
winWidth = documentElement.clientWidth;
winHeight = documentElement.clientHeight;
}
this.width = winWidth;
this.height = winHeight;
//alert(winWidth+" : "+winHeight);
}
/* 弹出框 */
function popupAlert(){
var d = new Dimensions();
window.onresize = Dimensions;
createMask(d.width, d.height, "#33393C", 0.5);
createBomb(d.width, d.height, 300, 150, "#EFEFEF");
}
/** 创建遮罩层 */
function createMask(winWidth , winHeight , background , opacity){
var mask = document.createElement("div"); //创建遮罩层
mask.id = "mask"; //设置遮罩层id
mask.style.position = "absolute"; //遮罩层位置
mask.style.zIndex = "1"; //遮罩层zIndex
mask.style.width = winWidth+"px"; //设置遮罩层宽度
mask.style.height = winHeight+"px"; //设置遮罩层高度
mask.style.top = "0px"; //设置遮罩层于上边距离
mask.style.left = "0px"; //设置遮罩层左边距离
mask.style.background = "#33393C"; //#33393C//遮罩层背景色
mask.style.filter = "alpha(opacity="+parseInt(opacity * 100)+")"; //遮罩层透明度IE
mask.style.opacity = opacity+"0"; //遮罩层透明度FF
document.body.appendChild(mask); //遮罩层添加到DOM中
};
/** 创建弹出层 */
function createBomb(winWidth, winHeight, width , height , background){
var bomb = document.createElement("div");
bomb.id = "bomId";
bomb.style.position = "absolute";
bomb.style.zIndex = "9999";
bomb.style.width = width+"px";
bomb.style.height = height+"px";
bomb.style.top = (winHeight/2 - height/2)+"px";
bomb.style.left = (winWidth/2 - width/2)+"px";
bomb.style.background = "#EFEFEF";
bomb.style.border = "1px solid #860001";
bomb.style.padding = "5px";
bomb.innerHTML = "新弹出层内容。。。";
document.body.appendChild(bomb);
};
function Dimensions(){
var windowWidth = window.innerWidth;
var windowHeight = window.innerHeight;
if(windowWidth){
winWidth = windowWidth
}else if((document.body) && (document.body.clientWidth)){
winWidth = document.body.clientWidth;
}
if(windowHeight){
winHeight = windowHeight;
}else if(document.body && document.body.clientHeight){
winHeight = document.body.clientHeight;
}
var documentElement = document.documentElement;
if(documentElement && documentElement.clientWidth && documentElement.clientHeight){
winWidth = documentElement.clientWidth;
winHeight = documentElement.clientHeight;
}
this.width = winWidth;
this.height = winHeight;
//alert(winWidth+" : "+winHeight);
}
/* 弹出框 */
function popupAlert(){
var d = new Dimensions();
window.onresize = Dimensions;
createMask(d.width, d.height, "#33393C", 0.5);
createBomb(d.width, d.height, 300, 150, "#EFEFEF");
}
/** 创建遮罩层 */
function createMask(winWidth , winHeight , background , opacity){
var mask = document.createElement("div"); //创建遮罩层
mask.id = "mask"; //设置遮罩层id
mask.style.position = "absolute"; //遮罩层位置
mask.style.zIndex = "1"; //遮罩层zIndex
mask.style.width = winWidth+"px"; //设置遮罩层宽度
mask.style.height = winHeight+"px"; //设置遮罩层高度
mask.style.top = "0px"; //设置遮罩层于上边距离
mask.style.left = "0px"; //设置遮罩层左边距离
mask.style.background = "#33393C"; //#33393C//遮罩层背景色
mask.style.filter = "alpha(opacity="+parseInt(opacity * 100)+")"; //遮罩层透明度IE
mask.style.opacity = opacity+"0"; //遮罩层透明度FF
document.body.appendChild(mask); //遮罩层添加到DOM中
};
/** 创建弹出层 */
function createBomb(winWidth, winHeight, width , height , background){
var bomb = document.createElement("div");
bomb.id = "bomId";
bomb.style.position = "absolute";
bomb.style.zIndex = "9999";
bomb.style.width = width+"px";
bomb.style.height = height+"px";
bomb.style.top = (winHeight/2 - height/2)+"px";
bomb.style.left = (winWidth/2 - width/2)+"px";
bomb.style.background = "#EFEFEF";
bomb.style.border = "1px solid #860001";
bomb.style.padding = "5px";
bomb.innerHTML = "新弹出层内容。。。";
document.body.appendChild(bomb);
};
- JavaScript 遮罩
- JavaScript 遮罩
- javascript遮罩
- JavaScript锁屏 遮罩【转】
- Javascript
- JavaScript
- javascript
- javascript
- javascript
- javascript
- javascript
- JavaScript
- javascript
- JavaScript
- Javascript
- javascript
- javascript
- JavaScript
- hdu 4359 easy tree dp? dp+combination
- C++内存管理变革(7)
- 电脑组装(配置)(1.频率问题)
- Iterator和foreach循环
- POJ 3575(计算几何与二分-无尽的小数处理)
- JavaScript 遮罩
- sharepoint 添加用户组,获取用户组集合中的用户组
- 利用switch语句编写猜数字(1~10)小游戏
- 旧工程适配iOS6和iPhone5续之第三方静态库
- 中方对韩海警用橡皮弹致中国渔民死亡表示抗议-韩海警抓捕中国渔民-中韩渔业纠纷-非法捕捞
- 程序员,到了50岁你还愿意做编程吗?
- java容器类-----------------Map接口解析(六)
- x264编码器的参数设置。
- 虚数的意义(绝对经典)