<script type="text/javascript"> var domain='http://www.jkadhkfakshjdfhkashfdjaksf.com'; // Set your domain here. window.onbeforeunload = function() { if(this.location.href.indexOf(domain)==-1) { return "Are you sure you want to exit?"; } } </script>