发现了个好玩的东西,先保存博客

六号博客 2019-06-23 PM 122℃ 0条
    /COOKIE功能检查
    function fCheckCookie(){
    if(!navigator.cookieEnabled){
        alert("您好,您的浏览器设置禁止使用cookie\n请设置您的浏览器,启用cookie功能,再重新登录。");
    }
}

    //获取Cookie
    function fGetCookie(sName){
       var sSearch = sName + "=";
       if(document.cookie.length > 0){
          offset = document.cookie.indexOf(sSearch)
          if(offset != -1){
             offset += sSearch.length;
             end = document.cookie.indexOf(";", offset)
             if(end == -1) end = document.cookie.length;
             return unescape(document.cookie.substring(offset, end))
          }
          else return ""
       }
    }

//设置Cookie
function fSetCookie(name, value, isForever, domain){
    var sDomain = ";domain=" + (domain || gOption["sCookieDomain"] );
    document.cookie = name + "=" + escape(value) + sDomain + (isForever?";expires="+  (new Date(2099,12,31)).toGMTString():"");
}

 

/跨域调用方法
function fGetScript(sUrl){
    var oScript = document.createElement("script");
    oScript.setAttribute("type", "text/javascript");
    oScript.setAttribute("src", sUrl);
    try{oScript.setAttribute("defer", "defer");}catch(e){}
    window.document.body.appendChild(oScript);
标签: cookie, 跨域

非特殊说明,本博所有文章均为博主原创。

评论啦~