JS_百度,Google关键词获取
/*可获取用户,通过哪个关键词访问该页,可自行添加SOGOU,SOSO,有道等搜索引擎*/var refer=document.referrer; var sosuo=refer.split(".")[1];var grep=null;var str=null;var keyword=null;switch(sosuo){ case "baidu": grep=/wd\=.*\&/i; str=refer.match(grep) keyword=str.toString().split("=")[1].split("&")[0]; console.log(decodeURIComponent(keyword)); break; case "google": grep=/&q\=.*\&/i; str=refer.match(grep) keyword=str.toString().split("&")[1].split("=")[1]; console.log(decodeURIComponent(keyword)); break;}
TAG: