Iacopo Guarneri
Iacopo Guarneri

Reputation: 97

block the flow of javascript

If I write:

window.onbeforeunload = function(){ return 'exit?' ;};

I get a popup to stay / leave the page. you can create a custom pop-up in html?

the problem is this: if I create a popup html, which is activated only when you exit from the current page, and I will see him for half a second, then change page ... how can I fix this? I need something (like the command alert) I block the page until you press a button.

Upvotes: 0

Views: 111

Answers (1)

Eevee
Eevee

Reputation: 48536

You can't do that. Which is good, because it would be really damn irritating if every website could stop me from browsing away from the page until they felt like it.

onbeforeunload is the only mechanism you've got. It ensures the browser still has enough control to let me leave if I want to, and prevents you from sticking me in an alert loop or similar.

Upvotes: 3

Related Questions