zoukankan      html  css  js  c++  java
  • 保持div滚动条的状态 使用cookie记录位置

    <div class="mint" id="mint" style="position: absolute; left: 5px; top: 5px; right: 5px;
            bottom: 5px; auto; height: auto; overflow: scroll" onscroll="setCookie('t',this.scrollTop)">
            <div class="report_plfs">
                <a href="javascript:void(0);" class="radioA" showdiv="iconList"><b class="r_icon1"></b>
                    <em>图标排列</em> </a><a href="javascript:void(0);" showdiv="groupSort" class="radioA r_checked">
                        <b class="r_icon2"></b><em>分组排列</em> </a>
            </div> 

    </div>

    <script>
         function setCookie(cookieName, cookieValue) {
             var today = new Date();
             var expire = new Date();
             nMinutes = 100;
             expire.setTime(today.getTime() + nMinutes * 60 * 1000);
             document.cookie = cookieName + "=" + escape(cookieValue) + ";expires=" + expire.toGMTString();
         };

         function getCookie(c_name) {
             if (document.cookie.length > 0) {
                 c_start = document.cookie.indexOf(c_name + "=");
                 if (c_start != -1) {
                     c_start = c_start + c_name.length + 1;
                     c_end = document.cookie.indexOf(";", c_start);
                     if (c_end == -1) c_end = document.cookie.length;
                     return unescape(document.cookie.substring(c_start, c_end));
                 }
             }
             return "";
         };

         function getscrolltop() {
             var t = getCookie("t")
             if (t != "") { document.getElementById("mint").scrollTop = parseInt(t); }
         };

         window.onload = function () {
             getscrolltop();
         };
      </script>

  • 相关阅读:
    vue 父子组件通信props/emit
    mvvm
    Ajax
    闭包
    【CSS3】---only-child选择器+only-of-type选择器
    【CSS3】---last-of-type选择器+nth-last-of-type(n)选择器
    【CSS3】---first-of-type选择器+nth-of-type(n)选择器
    【CSS3】---结构性伪类选择器—nth-child(n)+nth-last-child(n)
    【CSS3】---结构性伪类选择器-first-child+last-child
    vue路由切换和用location切换url的区别
  • 原文地址:https://www.cnblogs.com/mylife_001/p/4583708.html
Copyright © 2011-2022 走看看