Вы можете отложить выполнение любого кода в javascript, установив таймаут:
function MyAlert(msg) {
alert(msg);
}
//By using a function object as the first parameter
//any variables you need to use/pass will still be in scope
var msg = "Hey there!";
var delay = 5000; //the delay in milliseconds to wait (in this case 5 seconds)
setTimeout(function() { MyAlert(msg); }, delay);