0

I want to make a different animation based on if someone is coming to my webpage from another page on the site, or if they are just coming to the website for the first time. I basically want to do:

if (coming from my page) {
    $(this).css('display': 'block');
    $(this).fadeOut();
}

3 Answers3

1

You need to access the webserver.

Using PHP, you can access the variable $_SERVER["HTTP_REFERER"], it has the answer to your questions, but it is not always filled by the User Agent (web browser).

Using ASP, the variable is: Request.ServerVariables("HTTP_REFERER")

Stephen Ostermiller
  • 23,933
  • 14
  • 88
  • 109
rmagalhaess
  • 373
  • 1
  • 2
  • 8
  • They are using JavaScript, so it would be `document.referrer`. Reference: [Can I get the referrer?](https://stackoverflow.com/questions/6856697/can-i-get-the-referrer) – Stephen Ostermiller May 04 '23 at 09:01
1

You can make a script that, selects every <a> element on your page. Then for the href="some_other_page_on_your_site" part you alter it like this:

href="some_other_page_on_your_site?coming_from_my_site=true"

Then on a page load you have to check if "coming_from_my_site" is included in document.location.search.

clankill3r
  • 9,146
  • 20
  • 70
  • 126
0
$ipAddress=$_SERVER['REMOTE_ADDR'];

How if you get your client ip address and insert it to your db, or you can put cookie. . .

[Detect if user is a first time visitor, if so, re-direct to page, if not, re-direct to another page

check that problem, I hope that can solve your problem

Community
  • 1
  • 1
ronydavid
  • 391
  • 1
  • 2
  • 11