zoukankan      html  css  js  c++  java
  • cookie设置和读取以及获取超链接参数

    function setCookie(c_name, value, expiredays) {
    var exdate = new Date()
    exdate.setDate(exdate.getDate() + expiredays)
    document.cookie = c_name + "=" + escape(value) +
    ((expiredays == null) ? "" : ";path=/;expires=" + exdate.toGMTString());
    document.cookie = c_name + "=" + escape(value) +
    ((expiredays == null) ? "" : ";expires=" + exdate.toGMTString())
    }
    //清除cookie
    function clearCookie(name) {
    setCookie(name, "", -1);
    }
    //获取cookie
    function getCookie(cname) {
    var arr = document.cookie.match(new RegExp("(^| )" + cname + "=([^;]*)(;|$)"));
    if (arr != null) return unescape(arr[2]);
    return null;
    }
    //获取超链接参数

    function GetQueryString(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if (r != null) return unescape(r[2]);
    return null;
    }

    每一步都是一个深刻的脚印
  • 相关阅读:
    iOS开源控件库收集
    Ruby中的几种除法
    Font
    PlaySound
    STL
    APIs
    cin and cout
    CreateWindow
    Introducing Direct2D
    VC 常用代码
  • 原文地址:https://www.cnblogs.com/chzlh/p/9636153.html
Copyright © 2011-2022 走看看