1. 程式人生 > >js獲取各搜索引擎的關鍵詞

js獲取各搜索引擎的關鍵詞

mat .... decode spa 解答 cti text .html component

//方法
function GetQueryString() {    
    var refer = document.referrer;
    refer = refer + ‘&‘;
    var matches = ‘‘;   
    if(refer.match(/(www|m|youxuan)\.baidu/)){
        matches = refer.match(/\W(wd|word)\=(.*?)\&/i);
        if(matches){
            matches = matches[2];
        }
    };
    
if(refer.match(/m\.sm\.cn/)) { matches = refer.match(/q\=(.*?)\&/i); if(matches) { matches = matches[1]; } }; if(refer.match(/sogou\.com/)) { matches = refer.match(/keyword\=(.*?)\&/i); if(matches) { matches = matches[1]; } };
if(refer.match(/so\.com/)) { matches = refer.match(/q\=(.*?)\&/i); if(matches) { matches = matches[1]; } }; if(matches && matches.indexOf("%") == 0) { matches = decodeURIComponent(matches); } else { matches = ‘‘; }; return
matches; }; // 調用方法 var $wd=GetQueryString(); if($wd&&$wd.length>0){ }else{ $wd=GetQueryString("word") } if($wd&&$wd.length>0){ $wd=decodeURIComponent($wd); $line=‘關於【“‘+$wd+‘”】的問題,很榮幸為您解答疑問!‘; }else{ $line=‘ 您好,這裏是......,請問有什麽可以幫到您?‘; } $(‘#textFirst‘).html($line+"<span class=\"red\">(咨詢)</span>");

js獲取各搜索引擎的關鍵詞