javascript - Delay redirect Page -


i have quick question:

i notice there difference between these 2 codes:

function urllogin() {   window.location = "http://crs.local"; }  settimeout(urllogin(),5000) 

if use this, redirected.

settimeout(function(){window.location = "http://crs.local"},5000); 

but one, works intended. want ask difference between two?

there should no difference, both should delayed 5 seconds. sure didn't have settimeout(urllogin(), 5000)? seems common mistake.

the correct way had before "corrected" question :d : settimeout(urllogin, 5000), passing function , not invoking it.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -