javascript - before unload is not working as expected -
here's problem, need trigger modal call action when user tries out page, know if use before unload event must show alert returning text string function , that's fine. no matter do, alert before modal , when user has agreed stay on page built in browser alert.
i've seen in website, fronted genius managed open html modal right before alert displays, can see modal there.
here's code i'm using:
$(window).bind('beforeunload', function() { _('#beforeunload').foundation('reveal', 'open'); return 'you still have 1 item in basket!'; })
how can trigger foundation modal before browser prompts user whether leave in page or not?
try;
window.onbeforeunload = function(e) { return 'dialog text here.'; };
https://developer.mozilla.org/en-us/docs/web/api/windoweventhandlers/onbeforeunload#example
Comments
Post a Comment