//trim try { document.execCommand("BackgroundImageCache",false,true); //有点浏览器不支持这句 } catch(exception) { } String.prototype.trim = function() { return this.replace(/(^\s*)|(\s*$)/g,""); } //encodeURIComponent String.prototype.encodeURI = function(){ return encodeURIComponent(this); } //检查是不是空白字符串,如果等于null或equals("")都返回true function isEmptyStr(text) { if(text==null) { return true; } else if(text=="") { return true; } else { return false; } } //utility function called by getCookie() function getCookieVal(offset) { var endstr = document.cookie.indexOf(";", offset); if(endstr == -1) { endstr = document.cookie.length; } return unescape(document.cookie.substring(offset, endstr)); } // primary function to retrieve cookie by name function getCookie(name) { 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; } //取得XMLHttpRequest对象 function getHttpRequest() { var the_http_request = false; //XMLHttpRequest对象 try { the_http_request = new XMLHttpRequest(); } catch (trymicrosoft) { try { the_http_request = new ActiveXObject("Msxml2.XMLHTTP"); } catch (othermicrosoft) { try { the_http_request = new ActiveXObject("Microsoft.XMLHTTP"); } catch (failed) { the_http_request = false; } } } return the_http_request; } //取得当前域名部分包括http:// function getDomain() { var url=document.location.href; var a1=url.indexOf("."); var b1=url.indexOf("/",a1); return url.substring(0,b1); } var http_request; //XMLHttpRequest对象 //邀请查询 function inviteQuery() { if(http_request==null) { http_request=getHttpRequest(); } if (!http_request) { alert("XMLHttpRequest 初始化失败!"); } else { if(getCookie("visitorID")==null) { return; } var url=getDomain() + "/visitor/record/inviteQuery.asp?visitorID=" + getCookie("visitorID"); //document.write(url); http_request.open("GET", url, true); //打开请求 http_request.onreadystatechange = inviteQuery_updatePage; //设置回调方法 //http_request.setRequestHeader("Content-length", url.length); //http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); http_request.send(null); //发送请求 } return false; } //回调方法 function inviteQuery_updatePage() { if (http_request.readyState == 4) { if(http_request.status == 200) { if(!isEmptyStr(http_request.getResponseHeader("msg"))) { if(http_request.getResponseHeader("msg")=="1") //当有邀请时 { var bodyWidth=document.body.clientWidth; var bodyHeight=document.body.clientHeight; document.getElementById("id_invite").style.left=bodyWidth/2-439/2; document.getElementById("id_invite").style.top=bodyHeight/2-159/2; document.getElementById("id_invite").style.display=""; document.getElementById("id_invite").innerHTML= http_request.responseText; //decodeURI } } } else { if(!isEmptyStr(http_request.responseText)) { alert("错误:\n" + http_request.responseText); } } } } //不接受请求 function hideInvite() { document.getElementById("id_invite").style.display="none"; if(timerID!=null) { clearInterval(timerID); } } function drag(o,s) { if (typeof o == "string") o = document.getElementById(o); o.orig_x = parseInt(o.style.left) - document.body.scrollLeft; o.orig_y = parseInt(o.style.top) - document.body.scrollTop; o.orig_index = o.style.zIndex; o.onmousedown = function(a) { this.style.cursor = "move"; this.style.zIndex = 10000; var d=document; if(!a)a=window.event; var x = a.clientX+d.body.scrollLeft-o.offsetLeft; var y = a.clientY+d.body.scrollTop-o.offsetTop; d.ondragstart = "return false;" d.onselectstart = "return false;" d.onselect = "document.selection.empty();" if(o.setCapture) o.setCapture(); else if(window.captureEvents) window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP); d.onmousemove = function(a) { if(!a)a=window.event; o.style.left = a.clientX+document.body.scrollLeft-x; o.style.top = a.clientY+document.body.scrollTop-y; o.orig_x = parseInt(o.style.left) - document.body.scrollLeft; o.orig_y = parseInt(o.style.top) - document.body.scrollTop; } d.onmouseup = function() { if(o.releaseCapture) o.releaseCapture(); else if(window.captureEvents) window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP); d.onmousemove = null; d.onmouseup = null; d.ondragstart = null; d.onselectstart = null; d.onselect = null; o.style.cursor = "normal"; o.style.zIndex = o.orig_index; } } if (s) { var orig_scroll = window.onscroll?window.onscroll:function (){}; window.onscroll = function() { orig_scroll(); o.style.left = o.orig_x + document.body.scrollLeft; o.style.top = o.orig_y + document.body.scrollTop; } } } var timerID; var isProduct=""; if(document.location.href.toLowerCase().indexOf("detail_product.asp")>0 || document.location.href.toLowerCase().indexOf("detail_product_e.asp")>0) { isProduct="&isProduct=1"; } document.write(''); document.write(''); drag("id_invite"); timerID=setInterval("inviteQuery()",5000); //定时器