cannot react to close tab event with cloudfare app


#1

I am using the app creator and trying to react to close tab window event using the code below. I then preview the app in a separate window, but when I close the tab I don’t get the confirmation pop up. When I inject this code in the js console it works as expected. Doesn’t cloudfare app support such functionality?

window.onbeforeunload = function (e) {
// Your logic to prepare for 'Stay on this Page' goes here

return "Please click 'Stay on this Page' and we will give you candy";
};

#2

Hi again Amir! Sorry took we a few days to get to this on the community channel, but posted answer for future reference is here: https://stackoverflow.com/questions/50751457/cannot-react-to-close-tab-event-with-cloudfare-app


#3

cool. no worries.