Page Redirect after X seconds wait using JavaScript
You actually need to pass a function inside the window.setTimeout()
which you want to execute after 5000 milliseconds, like this:
$(document).ready(function () {
// Handler for .ready() called.
window.setTimeout(function () {
location.href = "https://www.google.co.in";
}, 5000);
});
For More info: .setTimeout()
You can use this JavaScript function. Here you can display Redirection message to the user and redirected to the given URL.
<script type="text/javascript">
function Redirect()
{
window.location="http://www.newpage.com";
}
document.write("You will be redirected to a new page in 5 seconds");
setTimeout('Redirect()', 5000);
</script>
It looks you are almost there. Try:
if(error == true){
// Your application has indicated there's an error
window.setTimeout(function(){
// Move to a new location or you can do something else
window.location.href = "https://www.google.co.in";
}, 5000);
}