用于检测来自谷歌的访问者的基本Javascript RegExp

时间:2022-03-22 15:19:25

I've to discover were the user come from and if he comes from google (search) I have to show a greeting box (in my blog).

我必须发现用户来自哪里,如果他来自谷歌(搜索),我必须显示一个问候语框(在我的博客中)。

I've a script really well done, but I don't know how to modify it to refer to all the visitors coming from google.

我有一个非常出色的脚本,但是我不知道如何修改它来引用所有来自谷歌的访问者。

if(referrer == "http://www.smashingmagazine.com/"){

This is the part of the script to modify.

这是要修改的脚本的一部分。

How can this match all the visitors coming from google (all the different possible urls).

如何匹配来自谷歌的所有访问者(所有可能的url)。

1 个解决方案

#1


3  

How about

如何

if (referrer.match(/google\.com/)) {}

?

吗?

#1


3  

How about

如何

if (referrer.match(/google\.com/)) {}

?

吗?