博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
遮罩层
阅读量:7069 次
发布时间:2019-06-28

本文共 3297 字,大约阅读时间需要 10 分钟。

hot3.png

1.页面代码:

    遮层   
  
    
  
 

2.JS代码(layer.js):

//加载遮层function showLoad(tipInfo) {    var iWidth = 150;     //弹出窗口的宽度;    var iHeight = 0;    //弹出窗口的高度;    var scrolltop = 0;    var scrollleft = 0;    var cheight = 0;    var cwidth = 0;    var eTip = document.createElement('div');    eTip.setAttribute('id', 'tipDiv');    eTip.style.position = 'absolute';    eTip.style.display = 'none';    eTip.style.border = 'solid 0px #D1D1D1';    //eTip.style.backgroundColor = '#4B981D';    eTip.style.padding = '5px 5px';    eTip.style.zindex = "9999999";    if(document.body.scrollTop){//这是一个js的兼容        scrollleft=document.body.scrollLeft;        scrolltop=document.body.scrollTop;        cheight=document.body.clientHeight;        cwidth=document.body.clientWidth;    }else{        scrollleft=document.documentElement.scrollLeft;        scrolltop=document.documentElement.scrollTop;        cheight=document.documentElement.clientHeight;        cwidth=document.documentElement.clientWidth;    }    iHeight = eTip.offsetHeight;    var v_left=(cwidth-iWidth)/2 + scrollleft; //    var v_top=(cheight-iHeight)/2+ scrolltop-50;    eTip.style.left = v_left + 'px';    eTip.style.top = v_top + 'px';    window.onresize=function(){        if(document.body.scrollTop){            eTip.style.left = (document.body.clientWidth-iWidth)/2+document.body.scrollLeft;            eTip.style.top =(document.body.clientHeight-iHeight)/2+document.body.scrollTop-50;        }else{            eTip.style.left = (document.documentElement.clientWidth-iWidth)/2+document.documentElement.scrollLeft;            eTip.style.top =(document.documentElement.clientHeight-iHeight)/2+document.documentElement.scrollTop-50;        }    }    eTip.innerHTML = '
' + tipInfo + '
';    try {        document.body.appendChild(eTip);    } catch (e) { }    $("#tipDiv").css("float", "right");    $("#tipDiv").css("z-index", "999999999");    $('#tipDiv').show();    ShowMark();}//关闭层function closeLoad() { try{     $('#tipDiv').hide();     HideMark();    }catch(e){}}//显示蒙灰层function ShowMark() {    var xp_mark = document.getElementById("xp_mark");    if (xp_mark != null) {        //设置DIV        xp_mark.style.left = 0 + "px";        xp_mark.style.top = 0 + "px";        xp_mark.style.position = "absolute";        xp_mark.style.backgroundColor = "#F1EDED";        xp_mark.style.zIndex = "999999998";        if (document.all) {            xp_mark.style.filter = "alpha(opacity=75)";            var Ie_ver = navigator["appVersion"].substr(22, 1);            if (Ie_ver == 6 || Ie_ver == 5) {                 hideSelectBoxes();            }        }else { xp_mark.style.opacity = "0.7"; }        xp_mark.style.width = "100%";        xp_mark.style.height = "100%";        xp_mark.style.display = "block";    }else {        //页面添加div explainDiv,注意必须是紧跟body 内的第一个元素.否则IE6不正常.        $("body").prepend("
");        ShowMark(); //继续回调自己    }}//隐藏蒙灰层function HideMark() {    var xp_mark = document.getElementById("xp_mark");    xp_mark.style.display = "none";    var Ie_ver = navigator["appVersion"].substr(22, 1);    if (Ie_ver == 6 || Ie_ver == 5) {         showSelectBoxes();    }}

动态gif图片:133127_RqbQ_658145.gif

效果图:

133032_ygUG_658145.png

 

转载于:https://my.oschina.net/4k9LCGA/blog/311688

你可能感兴趣的文章
分布式事务的解决方案
查看>>
Flutter-基础认知
查看>>
归档 OmniFocus 中已完成的任务到 印象笔记 Evernote
查看>>
移动端布局 全套解决方案 (附代码)
查看>>
ObjC 多线程简析(二)- os_unfair_lock的类型和自旋锁与互斥锁的比较
查看>>
结构模式 01-外观模式(facade)
查看>>
源码阅读:AFNetworking(十二)——UIButton+AFNetworking
查看>>
Kubernetes Helm入门指南
查看>>
用commander做一个自己的eslint脚手架
查看>>
iOS下JS与OC互相调用(五)--UIWebView + WebViewJavascriptBridge
查看>>
C++检索
查看>>
优化体系结构 - 数据外置减少中间表
查看>>
PAT A1120
查看>>
如何在 Titanic Kaggle Challenge 中获得0.8134分
查看>>
前端新手秘籍丶
查看>>
【跃迁之路】【727天】程序员高效学习方法论探索系列(实验阶段484-2019.2.17)...
查看>>
redux源码解析
查看>>
从理论到实践 全面理解HTTP/2
查看>>
vue2.X 解决同一路由跳转只有参数变化的情况下,组件不刷新的问题
查看>>
深度强化学习DQN(Deep Q Network)原理及例子:如何解决迷宫问题,附源码
查看>>