Forum Academy Marketplace Showcase Pricing Features

Add background popup using beforeunload

Sometimes a customer doesn’t like what numbers are given or if they qualify, I’d like to offer them a special rate based on the information they put in. I’ve tried using plugins that works based on cursor location but then it’s too easy to activate.

My idea was to create a custom plugin that would only activate when trying to change the page and I made sure that if they accepted the initial offer, they wouldn’t get a notification like they would if they have intentions on leaving. If they tried leaving, they would get that unsaved work popup but I wanted to have another popup in the background like an alert.

To get an example you can visit this link: https://jsfiddle.net/sy3fda05/2/
(this appears to only work with FireFox)

My problem right now is that bubble doesn’t activate #leavewarning in the css header which I’ve successfully verified to load and will go straight to the return statement giving the typical popup about unsaved work.

I’d appreciate it if someone could suggest a workaround for this issue.

Anyone have an idea?