Sad Trumbone When Someone Leaves Your Website

Ladies and Gentlemen, I give you: Sad Trumbone When Someone Leaves Your Website

This cutting edge HTML5 Audio technique can be easily achieved. Simply add an audio element to your page.

<audio id="sad" src=""></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
  //Return prompt message
  return "Are you sure want to leave? I mean, I am a pretty great site.";

About Banzor

Chris Bannon is a Corny Dad. He is a Certified Internet Webmaster and a purveyor of Fine Scripts. Chris is a Both-end Developer from JS to C#. And a Grinder for the Pittsburgh Pharaohs hockey team. View all posts by Banzor →

Comments are closed.