Safari preventDefault() is not working with AudioContext

117 views Asked by At

When the user closes the browser tab, I am showing a dialog box with the help of "beforeunload" event. Following is the code I used.

window.onbeforeunload = function(event) {
   event.preventDefault();
   event.returnValue = "";
};

This code works in chrome, firefox in all cases. But when it comes to safari, dialog box doesn't show up if I created a GainNode using audioContext.createGain(). How do i show dialog box even after creating GainNode?

0

There are 0 answers