window.onload = function () { var hasCookie = $.cookie("_gpdr_consent"); if (hasCookie == 1) { $("#cookie-box").css("display", "none"); } else { $("#cookie-box").css("display", "block"); } } //关闭底部广告 function closeFootAd() { $("#cookie-box").css("display", "none"); setCookie("_gpdr_consent", "1"); } //设置cookie function setCookie(name, value) { $.cookie(name, value, { expires: 365, path: '/', domain: GetCookieDomain() }); } //domain跨域 function GetCookieDomain() { var host = location.hostname; var ip = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/; if (ip.test(host) === true || host === 'localhost') return host; var regex = /([^]*).*/; var match = host.match(regex); if (typeof match !== "undefined" && null !== match) host = match[1]; if (typeof host !== "undefined" && null !== host) { var strAry = host.split("."); if (strAry.length > 1) { host = strAry[strAry.length - 2] + "." + strAry[strAry.length - 1]; } } return '.' + host; }