Sprawdź granicę błędu. Wydaje mi się, że 100ms jest ok. Oczywiście polecam to skompresować np. http://jscompress.com/
var openSite = function( args ) {
check_args( args );
function check_args( args ){
if( args == undefined ){
return;
}
else if( args['time'] == undefined || args['time'] == '' ){
if( (args['url'] == undefined || args['url'] == '') ){
if( args.length > 0 ){
window.open( args );
}
}
else{
window.open( args['url'] );
}
return;
}
var target = new Date();
var time = args['time'].split(":");
target.setHours( time[0] );
target.setMinutes( time[1] );
target.setSeconds( time[2] );
if( isNaN(target) ){
return;
}
exec({
time: target,
url: args['url']
});
}
function exec( args ){
if( args['time'] - (new Date()) > 100 ){
setTimeout( function(){
exec( args );
}, 1000 );
}
else{
window.open( args['url'] );
}
}
};
openSite("https://google.com");
openSite({
url: "https://google.com"
});
openSite({
time: "15:00:00",
url: "https://google.com"
});