zoukankan      html  css  js  c++  java
  • js 弹出 隐藏层和cookie

    <script type="text/javascript">

    function checkCookie(show_div, bg_div) {
    var smtstk = getCookie('smtstk');
    if (smtstk == "no" ||smtstk=="") {//如果有cookie则不再展示
    //document.getElementById("tstk").style.display = "none";
    ShowDiv(show_div, bg_div);
    }
    else {
    //document.getElementById("tstk").style.display = "block";
    CloseDiv(show_div, bg_div);
    }
    }

    //弹出隐藏层
    function ShowDiv(show_div, bg_div) { //ShowDiv('MyDiv','fade')
    document.getElementById(show_div).style.display = 'block';
    document.getElementById(bg_div).style.display = 'block';
    var bgdiv = document.getElementById(bg_div);
    bgdiv.style.width = document.body.scrollWidth;
    $("#" + bg_div).height($(document).height());
    document.body.style.overflow = "hidden";

    };
    //关闭弹出层
    function CloseDiv(show_div, bg_div) {
    setCookie("smtstk", "no");
    document.getElementById(show_div).style.display = 'none';
    document.getElementById(bg_div).style.display = 'none';
    document.body.style.overflow = "scroll";
    };

    //读取cookie
    function getCookie(cname) {
    var name = cname + "=";
    var ca = document.cookie.split(';');
    for (var i = 0; i < ca.length; i++) {
    var c = ca[i];
    while (c.charAt(0) == ' ') c = c.substring(1);
    if (c.indexOf(name) != -1) return c.substring(name.length, c.length);
    }
    return "";
    }

    //设置cookie
    function setCookie(cname, cvalue) {
    document.cookie = cname + "=" + cvalue + "";
    }
    </script>

    至少证明我们还活着
  • 相关阅读:
    使用 GitHub, Jekyll 打造自己的免费独立博客
    如何解决数据科学计数法在数据库中的显示
    RDF
    C# 在 4.0 以后一共有3种创建线程的方式
    C#多线程
    1、框架概述
    3、IDEA 中使用 Maven
    2、Maven 核心概念
    1、Maven 概述
    JDK动态代理
  • 原文地址:https://www.cnblogs.com/pengde/p/5818243.html
Copyright © 2011-2022 走看看