This is a test of the beforeunload event!

      window.addEventListener('beforeunload', function(event) {
        return event.returnValue = 'Will you show this message?';

The above is the code that's running on this site.

To try it out, click this link, which is the MDN reference fore the beforeunload event.

In theory, it should show the message as assigned above, but there's a fun little note in the docs:

Some browsers display the returned string in the dialog box, but others display their own message.

As of 2017-09-27, it appears that the only modern browser that will show the message you assign is Internet Explorer (and Edge).