开发者

Webpage Reference using Javascript

I want to identify from where a visitor coming to my webpage.Is there anyways to getting that reference in a javascript file.eg: if my website is www.example.com.if user getting this site from google or bing search,then i need to identify that,user from googl开发者_StackOverflow社区e or bing respectivly.How can i get this in javascript(more priority) or in php.If anybody know help me please...


You want to get the Referer information.

In PHP, you can access it with $_SERVER['HTTP_REFERER'].

In Javascript, I suppose that this should give you that information : document.referrer.


Note : the referer is an information that's sent by the user's browser, which means :

  • It can, or cannot, be sent
    • Which means your application can use it to provide some additionnal stuff,
    • But must work even if the Referer is not there.
  • It can be forged
    • Which means you must not trust it for any important feature.
    • And you might want to filter/validate it
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜