javascript - Simple setTimeout not working? -


i trying create basic script in tampermonkey. visit 1 url, wait 1 second , visit another:

$(document).ready(function() {     document.location.href = 'http://www.google.com';     settimeout(dostuff ,1000); });  function dostuff(){     document.location.href = 'http://www.stackoverflow.com'; } 

the function dostuff not appear called ever. whenever run script, redirected google.com, not stackoverflow.com.

a javascript execution environment lasts lifetime of page.

when set location.href leave page, pending javascript won't run because environment no longer exists.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -