codice:
function conf() {
 var a = confirm("vuoi accedere al sito?");
 if (a) {
  //tutto a posto
  alert("ok! entra");
 }
 else {
  location.href = "http://www.google.com";
 }
}

<body onLoad="conf()">