Just for fun
You can have this html
<a class="fancybox" href="
http://stackoverflow.com">go to stackoverflow site</a>
<div id="confirm" style="display: none">
<p>are you sure you want to leave this page?</p><br />
<a href="javascript:;" class="confirm yes">yes</a>
<a href="javascript:;" class="confirm no">no</a>
</div>
and this script
$(".fancybox").on("click", function(e){
e.preventDefault();
var theSite = this.href;
$.fancybox("#confirm",{
modal: true,
afterShow: function(){
$(".confirm").on("click", function(event){
if($(event.target).is(".yes")){
window.location.href = ""+ theSite +"";
} else if ($(event.target).is(".no")){
$.fancybox.close();
}
});
}
})
});
See demo at
http://jsfiddle.net/8KdD4/show/Code
http://jsfiddle.net/8KdD4/