javascript - referring script stuck in a loop -
what trying redirect user based on referring url promo page. in script below if comes referring url “mydomainsite.com” sent “mydomainsite.com/promo.html” when have script below in page “mydomainsite.com/promo.html” , comes refer of “mydomainsite.com” seems loop or continue load page , never loads page “mydomainsite.com/promo.html” script has in “mydomainsite.com/promo.html,” page being promo page , can’t have access page. assume due indexof , checks “mydomainsite.com” executes. there away fix this?
<script language="javascript"> if (document.referrer.indexof('mydomainsite.com') > -1) location.href='http://mydomainsite.com/promo.html'; else location.href='http://notfrommydomainsite.com'; </script>
as has been mentioned in comments referrer
data not reliable, if want pursue this...
the mqost cause of issue have when arriving @ redirected promo.html
finds referrer mydomainsite.com
goes creating infinite loop.
you need test , avoid loop checking location.pathname
not promo.html
:
if (document.referrer.indexof ('mydomainsite.com') > -1 && location.pathname !== 'promo.html') location.href = 'http://mydomainsite.com/promo.html';
Comments
Post a Comment