문제

So I'm trying to make it so I go to another website after a certain number of seconds, however it doesn't appear to be working. I would expect my code (below) to go to youtube for 10 seconds and then it would change into google. What is the problem? Much appreciated.

window.location.assign("http://www.youtube.com");
setTimeout(doSomething, 10000);
function doSomething()
{
    window.location.replace("http://www.google.com");
}
도움이 되었습니까?

해결책

window.location.assign("http://www.youtube.com");

redirects to Youtube, so anything after that line is not executed as you're now on Youtube ?

다른 팁

Once the browser leaves the page your JavaScript stops processing too. You cant go to another site and then continue to run your JavaScript.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top