• JavaScript操作cookie


    以下操作cookie在Firefox和Safari中测试成功,在IE中失败(读取、获取,改写,设置)。

    经过反复测试,发现把http://127.0.0.1改为http://localhost之后,IE中也可以正常运行。

    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 (document.cookie.substring(c_start, c_end));
                 }
             }
             return ""
         }

         function setCookie(c_name, value, expiredays) {
             var exdate = new Date();
             exdate.setDate(exdate.getDate() + expiredays);
             document.cookie = c_name + "=" + value + ((expiredays == null) ? "" : ";expires=" + exdate.toGMTString()) + ";path=/";
             ;
         }

         function checkCookie() {
             master_headertop_narrow_show = getCookie('master_headertop_narrow_show')
             alert(master_headertop_narrow_show); //////
             if (master_headertop_narrow_show != null && master_headertop_narrow_show != "") {
                 if (master_headertop_narrow_show == 'true') {
                     var master_headertop = document.getElementById('master_headertop');
                     if (master_headertop)
                         master_headertop.style.display = 'none';
                     var master_headertop_narrow = document.getElementById('master_headertop_narrow');
                     if (master_headertop_narrow)
                         master_headertop_narrow.style.display = 'block';

                 }
             }
         }

  • 相关阅读:
    重学Java 面向对象 之 final
    java并发学习04---Future模式
    java并发学习03---CountDownLatch 和 CyclicBarrier
    java并发学习02---ReadWriteLock 读写锁
    java并发学习01 --- Reentrantlock 和 Condition
    链表的倒数第k个节点
    重建二叉树
    java并发学习--线程池(一)
    二叉树的深度
    vue-常用指令(v-for)
  • 原文地址:https://www.cnblogs.com/emanlee/p/1786390.html
Copyright © 2020-2023  润新知