Reputation:
My aim is to redirect user to a specific website for 18 seconds and then redirect back to my website. To accomplish this, I have written the code below. The problem I am facing was that the website started to redirect in a loop so I had to come up with a condition to avoid that. For this I have putted a check if the user is coming from my redirected website or not but now the redirection isnt working at all. Please guide. Thanks
Note: startupsandfinance is the domain name from which the user gets redirected back.
<script type='text/javascript'>
if !(( document.referrer.search("startupsandfinance"))){
document.cookie="toURL"+ "=" +escape(document.URL)+";path=/; domain=.mycsnippets.com";
document.cookie="refURL"+ "=" +escape(document.referrer)+";path=/; domain=.mycsnippets.com";
this.location='http://www.startupsandfinance.com/welcome.htm';
}
</script>
Upvotes: 0
Views: 44
Reputation: 664589
Please guide
if !((
is a syntax error!search()
will not work, since search
returns -1
when nothing is found and the index elsethis.location
, but window.location
<script>
tagsreferer
, it can easily be spoofed or is disabled. Use cookies instead: Before redirecting set it, when coming back you can check it.Upvotes: 2