-2

I was just wondering how I could make a person stay on a website for a specific time and then redirect them to a new website using JavaScript! Thanks for your help!

I repeat, using JavaScript, this is not the same as the other ones, I want to use JS

2 Answers2

1

Will take you to Google after 3 seconds.

var timer = setTimeout(function() { window.location.href = 'http://www.google.com'; }, 3000);

Please always set the timeout to variable for the possibility to clear the timeout.

clearTimeout(timer); 
Jan Franta
  • 1,691
  • 2
  • 16
  • 25
0
setTimeout(myFunction, 2000);

myFunction should use window.location.href = 'my_Link';

ajbee
  • 3,511
  • 3
  • 29
  • 56