Its because onbeforeunload event triggers not only when window closes but for hyperlink, document write/close actions etc. So need to exclude for such actions .
Try something like
jQuery(
function($)
{
$(window).data('beforeunload',window.onbeforeunload);
$('a[href^="javascript:"]')
.hover(
function(){window.onbeforeunload=null;},
function(){window.onbeforeunload=$(window).data('beforeunload');}
);
}
);
Or even
document.getElementById('hyperlinkid').onclick = function () {
window.onbeforeunload = null;
};
Hope this helps you...