• JavaScript 层


    代码Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--><script language="javascript">
    var docEle = function() {
    return document.getElementById(arguments[0]) || false;
    }
    function openNewDiv(_id) {
    var m = "mask";
    if (docEle(_id)) document.removeChild(docEle(_id));
    if (docEle(m)) document.removeChild(docEle(m));
    
    // 新激活图层
    var newDiv = document.createElement("div");
    newDiv.id = _id;
    newDiv.style.position = "absolute";
    newDiv.style.zIndex = "9999";
    newDiv.style.width = "500px";
    newDiv.style.height = "300px";
    newDiv.style.top = "50px";
    newDiv.style.left = (parseInt(document.body.scrollWidth) - 300) / 2 + "px"; // 屏幕居中
    newDiv.style.background = "#EFEFEF";
    newDiv.style.border = "1px solid #860001";
    newDiv.style.padding = "5px";
    newDiv.innerHTML = "新激活图层内容   ";
    document.body.appendChild(newDiv);
    
    // mask图层
    var newMask = document.createElement("div");
    newMask.id = m;
    newMask.style.position = "absolute";
    newMask.style.zIndex = "1";
    newMask.style.width = document.body.scrollWidth + "px";
    newMask.style.height = document.body.scrollHeight + "px";
    newMask.style.top = "0px";
    newMask.style.left = "0px";
    newMask.style.background = "#000";
    newMask.style.filter = "alpha(opacity=40)";
    newMask.style.opacity = "0.40";
    document.body.appendChild(newMask);
    // 关闭mask和新图层
    
    var newA = document.createElement("a");
    newA.href = "#";
    newA.innerHTML = "X";
    newA.onclick = function() {
      document.body.removeChild(docEle(_id));
      document.body.removeChild(docEle(m));
      return false;
    }
    newDiv.appendChild(newA);
    }
    </script>
    <body>
    <a href="#" onclick="openNewDiv('newDiv');return false;">激活新层</a>
    <p> 网页内容网页内容网页内容</p>
    <p>网页内容网页内容网页内容</p>
    </body>
  • 相关阅读:
    [bzoj5466] [loj#2955] [NOIP2018] 保卫王国
    [洛谷P4719] 动态DP模板
    [bzoj4869] [loj#2142] [Shoi2017] 相逢是问候
    《组合数学》学习笔记 之 二项式系数
    多项式模板合集
    THUWC2020 自闭记
    [bzoj5020] [THUWC 2017] 在美妙的数学王国中畅游
    [bzoj3676] [Apio2014] 回文串
    【模板整理】Tarjan
    考前一些东西
  • 原文地址:https://www.cnblogs.com/accumulater/p/6767154.html
Copyright © 2020-2023  润新知