网站商务通链接快速标识v1.0.js

js代码为:

function getSwt(keys){
    try{
        if(openZoosUrl&&typeof(openZoosUrl)=="function"){
            //LR_HideInvite();
            if(!keys){
                if(!(getsokey()[1]=="" || !getsokey()[1])){
                    keys=getsokey()[0]+" 【"+getsokey()[1]+"】";
                    openZoosUrl('chatwin','&e='+encodeURIComponent(keys));
                }else{
                    openZoosUrl();
                }

            }else{
                if(!(getsokey()[1]=="" || !getsokey()[1])){
                    var keyw=getsokey()[0]+" 【"+getsokey()[1]+"】";
                    openZoosUrl('chatwin','&e='+encodeURIComponent(keyw+"->"+keys));
                }else{
                    openZoosUrl('chatwin','&e='+encodeURIComponent(keys));
                }
            }
    }}catch(e){
        var keyword="";
        if(!(getsokey()[1]=="" || !getsokey()[1]))
            keyword=getsokey()[0]+" 【"+getsokey()[1]+"】";
        window.open("http://dgt.zoosnet.net/LR/Chatpre.aspx?id=你是商务通id&p="+window.location.href+"&e="+keyword);
    }

    return false;
}

// 判断页面是否加载商务通js
try{
    if(openZoosUrl&&typeof(openZoosUrl)=="function"){
}}catch(e){
    document.writeln('<script language="javascript" src="http://dgt.zoosnet.net/JS/LsJS.aspx?siteid=你是商务通id&float=0&lng=cn"></script>');
}   

function getDomainQuery(url) {
    var d = [];
    var st = url.indexOf('//', 1);
    var _domain = url.substring(st + 1, url.length);
    var et = _domain.indexOf('/', 1);
    d.push(_domain.substring(1, et));
    d.push(_domain.substring(et + 1, url.length));
    return d;
}

var eg = [];
eg.push(['jiankang.baidu', 'searchword']);
eg.push(['m.baidu', 'word']);
eg.push(['wap.baidu', 'wd']);
eg.push(['www.baidu', 'wd']);
eg.push(['google', 'q']);
eg.push(['soso', 'w']);
eg.push(['yodao', 'q']);
eg.push(['bing', 'q']);
eg.push(['yahoo', 'q']);
eg.push(['wap.sogou', 'keyword']);
eg.push(['m.sogou', 'keyword']);
eg.push(['mobi.sogou', 'keyword']);
eg.push(['www.sogou', 'query']);
eg.push(['gougou', 'search']);
eg.push(['360', 'q']);
eg.push(['haosou', 'q']);
eg.push(['sm', 'q']);
eg.push(['chinaso', 'q']);

var dq = getDomainQuery(document.referrer);
var keyword=null;
var grep=null;
var str=null;

for(var el in eg){
    var s = eg[el];
    var DandQ=String(s).split(",");
    if (dq[0].indexOf(DandQ[0])>0){
        eval("grep=/"+DandQ[1]+"\=.*\&/i;");
        str = dq[1].match(grep);
        keyword = str.toString().split("=")[1].split("&")[0];
        keyword = decodeURIComponent(keyword);
        document.cookie="search="+DandQ[0];
        document.cookie="wd="+keyword;
        }
}

// 判断是来自哪个搜索引擎的
function getsokey(){
    var strCookie=document.cookie;
    var arrCookie = strCookie.split("; ");
    var sokey = new Array();
    for(var i=0;i<arrCookie.length;i++){
        var arr=arrCookie[i].split("=");
        if("search"==arr[0]){
            if(arr[1]=="m.baidu"||arr[1]=="wap.baidu"||arr[1]=="www.baidu"){
                sokey[0]="百度搜索";
            }else if(arr[1]=="360"||arr[1]=="haosou"){
                sokey[0]="360搜索";
            }else if(arr[1]=="jiankang.baidu"){
                sokey[0]="百度健康";
            }else if(arr[1]=="sm"){
                sokey[0]="神马搜索";
            }else if(arr[1]=="m.sogou"||arr[1]=="mobi.sogou"||arr[1]=="wap.sogou"||arr[1]=="www.sogou"){
                sokey[0]="搜狗搜索";
            }else if(arr[1]=="google"){
                sokey[0]="谷歌搜索";
            }else if(arr[1]=="soso"){
                sokey[0]="搜搜搜索";
            }else if(arr[1]=="yodao"){
                sokey[0]="有道搜索";
            }else if(arr[1]=="bing"){
                sokey[0]="必应搜索";
            }else if(arr[1]=="yahoo"){
                sokey[0]="雅虎搜索";
            }else if(arr[1]=="gougou"){
                sokey[0]="狗狗搜索";
            }else if(arr[1]=="chinaso"){
                sokey[0]="中国搜索";
            }else{
                sokey[0]="搜索";
            }
        }
        if("wd"==arr[0]){
            sokey[1]=arr[1];
        }
    }
    return sokey;
}

调用的时候用

<a href="javascript:void(0);" onclick="return getSwt('从点击1进入');" >点击1</a>
<a href="javascript:getSwt('从点击2进入');">点击2</a>
<a href="javascript:void(0)" onclick="return getSwt();">点击3</a>
<a href="javascript:getSwt();">点击4</a>
上一篇:checkbox全选与非全选之间的切换


下一篇:BZOJ4818 [SDOI2017] 序列计数 【矩阵快速幂】