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


//方法
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>");

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM