/* * CDN counter * @lastmodify 2012.5.24 */ var __clientID = config.clientID; var __projectID = config.projectID; var __gbookStyle = config.gbookStyle; var __helper = config.helper; var __seat = config.seat; var __custid = config.custid; var __activeStatus = config.activeStatus; var __myIframeHeight = 580; var __showtel400 =config.showtel400;//400大号 var str= window.location.href; var selfUrl = escape(top.location.href); var selfUrl2 = encodeURIComponent(top.location.href); var selfTitle = escape(top.document.title); var comeUrl = top.document.referrer; var es=/./; es.exec(str); var right=RegExp.rightContext; var txt; txt = right.split("?"); var sParam; sParam = "&" + txt[1]; if(sParam == "&undefined") { str = document.referrer; es=/./; es.exec(str); right=RegExp.rightContext; txt = right.split("?"); sParam = "&" + txt[1]; } if(sParam == "&undefined") { sParam = ""; } //只取comeUrl路径,不取参数 var cometxt = comeUrl.split("?"); var come_str = cometxt[0]; var comeUrl_new = escape(top.document.referrer); //仿counter.php进行处理 var bannerID = parseInt(GetQueryString("bannerID"),10); if(isNaN(bannerID)) bannerID = parseInt(GetQueryString("bannerid"),10);//兼容小写 var newComeID = parseInt(GetQueryString("comeID"),10); if(isNaN(newComeID)) newComeID = parseInt(GetQueryString("comeid"),10);//兼容小写 if(isNaN(bannerID)) bannerID = 0; if(isNaN(newComeID)) comeID = parseInt(GetCookie("comeID"),10); else comeID = newComeID; //去掉hao123的comeID var re = "/hao123.com/i"; if (comeUrl_new.search(re)) { comeID = 20504; } SetCookie("comeID",comeID); var free_keywordID = parseInt(GetQueryString("fk"),10); if(isNaN(free_keywordID)) fk = parseInt(GetCookie("comeID"),10); else fk = free_keywordID; if(isNaN(fk)) fk = 0; SetCookie("free_keywordID",fk); // 新advert 添加cookie 20150615 此函数于其余各站点count 或countnew 有所不同 [区别在于获取地址栏参数方法 请注意] var _advertHref = document.location.href; var _host = window.location.host; var _Domain = _host.substr( _host.indexOf('.')); var _advsiteid = GetQueryString('advsiteid') ? GetQueryString('advsiteid') : 0; var _advplanid = GetQueryString('advplanid') ? GetQueryString('advplanid') : 0; var _advunitid = GetQueryString('advunitid') ? GetQueryString('advunitid') : 0; var _advkid = GetQueryString('advkid') ? GetQueryString('advkid') : 0; var _advert = '{"advsiteid":"'+_advsiteid+'","advplanid":"'+_advplanid+'","advunitid":"'+_advunitid+'","advkid":"'+_advkid+'"}'; if(_advsiteid && _advkid) document.cookie = "advert="+encodeURIComponent(_advert)+"; Path=/; domain="+_Domain; if(__gbookStyle > 0) { if(__activeStatus == '1'){ __myIframeHeight = 580; } var tq_clientid_tq = typeof tq_clientid == 'undefined' ? 0 : tq_clientid; // 新增advert 获取cookie 如果获取不到 传送默认值 var __advert = ''; var __cookie = document.cookie.split(';'); for(var i in __cookie){ if(__cookie[i].indexOf('advert') > 0){ __advert = __cookie[i].split('='); } } if(__advert){ var __advert = decodeURIComponent(__advert[1]); var Obj_advert = eval('('+__advert+')'); tq_clientid_tq += '_'+Obj_advert.advsiteid+'-'+Obj_advert.advplanid+'-'+Obj_advert.advunitid+'-'+Obj_advert.advkid+'_pc'; }else{ tq_clientid_tq += '_0-0-0-0_pc'; } //end document.write(""); } if(comeUrl_new) { if (!comeUrl_new.search(/28.com/)) SetCookie("comeUrl",comeUrl_new); } var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://"); document.write(unescape("%3Cscript src='" + _bdhmProtocol + "hm.baidu.com/h.js%3Fe5d45167151d43ae30f15d82621a8635' type='text/javascript'%3E%3C/script%3E")); /** * 以上为执行主体代码,以下为函数区域 */ //iframe高度自适应 function SetCwinHeight(id){ var bobo=document.getElementById(id); //iframe id if (document.getElementById){ if (bobo && !window.opera){ if (bobo.contentDocument && bobo.contentDocument.body.offsetHeight){ bobo.height = bobo.contentDocument.body.offsetHeight; }else if(bobo.Document && bobo.Document.body.scrollHeight){ bobo.height = bobo.Document.body.scrollHeight; } } } } //获取URL参数 function GetQueryString(name) { var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)","i"); var r = window.location.search.substr(1).match(reg); if (r!=null) return unescape(r[2]); return null; } /** JS cookie 操作函数 start */ function GetCookieVal(offset) //获得Cookie解码后的值 { var endstr = document.cookie.indexOf (";", offset); if (endstr == -1) endstr = document.cookie.length; return unescape(document.cookie.substring(offset, endstr)); } function SetCookie(name, value) //设定Cookie值 { var expdate = new Date(); var argv = SetCookie.arguments; var argc = SetCookie.arguments.length; var expires = (argc > 2) ? argv[2] : null; var path = (argc > 3) ? argv[3] : null; var domain = (argc > 4) ? argv[4] : null; var secure = (argc > 5) ? argv[5] : false; if(expires!=null) expdate.setTime(expdate.getTime() + ( expires * 1000 )); document.cookie = name + "=" + escape (value) +((expires == null) ? "" : ("; expires="+ expdate.toGMTString())) +((path == null) ? "" : ("; path=" + path)) +((domain == null) ? "" : ("; domain=" + domain)) +((secure == true) ? "; secure" : ""); } function DelCookie(name) //删除Cookie { var exp = new Date(); exp.setTime (exp.getTime() - 1); var cval = GetCookie (name); document.cookie = name + "=" + cval + "; expires="+ exp.toGMTString(); } function GetCookie(name) //获得Cookie的原始值 { var arg = name + "="; var alen = arg.length; var clen = document.cookie.length; var i = 0; while (i < clen) { var j = i + alen; if (document.cookie.substring(i, j) == arg) return GetCookieVal (j); i = document.cookie.indexOf(" ", i) + 1; if (i == 0) break; } return null; } /** JS cookie 操作函数 end */