Ladies and Gentlemen, I give you: Sad Trumbone When Someone Leaves Your Website
http://jsbin.com/OMEKObA/1/
This cutting edge HTML5 Audio technique can be easily achieved. Simply add an audio element to your page.
<audio id="sad" src="http://soundfxnow.com/soundfx/Sad-Trombone.mp3"></audio>
Then bind the onbeforeunload
event and call the play()
method on the audio
element before returning the prompt message.
//Bind window unload event window.onbeforeunload = function() { //Play sad trumbone document.getElementById('sad').play(); //Return prompt message return "Are you sure want to leave? I mean, I am a pretty great site."; };