GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Webmaster Q & Fuckin' A (https://gfy.com/forumdisplay.php?f=27)
-   -   javascript (https://gfy.com/showthread.php?t=1138373)

CPA-Rush 04-14-2014 04:33 PM

javascript
 
i need to redirect based on referrer

for example

#if source www.site.com/folder/0123 >> go link1

or
##if source www.site.com/folder/4567 >> go link 2

or
##if source www.site.com/folder/89xx >> go link3

else , in case the user doesn?t sent his referrer or come from any other source >> just go link4

PS: my current redirect script is .js file not inside html file

thanks

Tdash 04-14-2014 06:09 PM

Javascript? It can easily be done in php.

CPA-Rush 04-15-2014 03:21 AM

the reason i prefer javascript because i will be able to see stats via analytic

php execute faster than anything else :error

sarettah 04-15-2014 03:18 PM

Simple version:

<script type="text/javascript">

if(document.referrer=='http://www.site.com/folder/0123')
{
window.location='http://whatever_url_1.com ';
}
else if(document.referrer=='http://www.site.com/folder/4567')
{
window.location='http://whatever_url_2.com ';
}
else if(document.referrer=='http://www.site.com/folder/89xx')
{
window.location='http://whatever_url_3.com ';
}
else
{
window.location='http://whatever_url_4.com ';
}

</script>

CPA-Rush 04-15-2014 03:40 PM

thanks sarettah i will try this code +1 :thumbsup

CPA-Rush 04-16-2014 03:21 AM

sarettah this worked with me just after doing little change


Code:

if (document.referrer.indexOf('https://gfy.com/') > -1)
    {
    window.location='http://yahoo.com';
}
else if (document.referrer.indexOf('https://gfy.com/forum') > -1)
    {
    window.location='http://msn.com';
}
else
  {
    window.location='http://www.google.com';
}


:thumbsup

thanks

Quote:

Browsers do not always provide a document.referrer. If the referrer is from a https it is blocked, or if the security settings in the broswer block it none is provided. These people will never get past the page and will be cut off from being able to use your site
they will go to http://www.google.com , right ?

sarettah 04-16-2014 07:00 AM

Quote:

Originally Posted by rosx (Post 20051621)
sarettah this worked with me just after doing little change


Code:

if (document.referrer.indexOf('https://gfy.com/') > -1)
    {
    window.location='http://yahoo.com';
}
else if (document.referrer.indexOf('https://gfy.com/forum') > -1)
    {
    window.location='http://msn.com';
}
else
  {
    window.location='http://www.google.com';
}


Well, it appears to me that you will never send anyone to msn.com with that.

Your first condition document.referrer.indexOf('https://gfy.com/') > -1 should send anyone from gfy to yahoo. Since the second condition also includes the first condition it will never be hit.

So, if you wanted to do that switch condition 1 and 2 around. Make condition 1 be gfy.com/forum and condition 2 be just gfy. That way the ones to the forums will be redirected to msn and then anyone else from gfy will be redirected to yahoo.

I had done the exact match conditions because you had included specific pages in your example. As I said, it was a very simple version.

Glad it worked for you.

.

CPA-Rush 04-16-2014 07:16 AM

Quote:

Originally Posted by sarettah (Post 20051846)
Well, it appears to me that you will never send anyone to msn.com with that.

Your first condition document.referrer.indexOf('https://gfy.com/') > -1 should send anyone from gfy to yahoo. Since the second condition also includes the first condition it will never be hit.

So, if you wanted to do that switch condition 1 and 2 around. Make condition 1 be gfy.com/forum and condition 2 be just gfy. That way the ones to the forums will be redirected to msn and then anyone else from gfy will be redirected to yahoo.

I had done the exact match conditions because you had included specific pages in your example. As I said, it was a very simple version.

Glad it worked for you.

.

http://tacticalip.com/wp-content/upl...impson-doh.gif

i will correct that and remove that switch " > -1)"

tnx for the heads up , cheers :)

Kafka 04-30-2014 05:15 AM

I suggest you should use ModRewrite (htaccess) with that.

CPA-Rush 04-30-2014 08:47 PM

Quote:

Originally Posted by Kafka (Post 20068702)
I suggest you should use ModRewrite (htaccess) with that.

i need to keep the analytics stats :)


All times are GMT -7. The time now is 12:31 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc