James Kirkby James Kirkby - 5 months ago 31x
Javascript Question

Unbind window.onbeforeunload() cancel

i'm binding a function to an event with

window.onbeforeunload = function() {

which is working on unload as planned, but if they cancel the onbeforeunload the function is still attached, is it possible to check if the user cancels onbeforeunload


Actually, I found it was quite easy: I just set

window.onbeforeunload = null;

for each click before it was run, allowing the event handler to be run afterwards.