Reputation: 456
Is it possible to prevent a user from closing a JavaScript alert until 10 seconds have passed?
I trigger an alert, and then user must wait "x" seconds to be able to close it.
Upvotes: 0
Views: 762
Reputation: 17451
Here's a better way:
You'll want to avoid alert, since you have no control over the dialog box with it. Instead, try a modal dialog like ThickBox. It's a jQuery plugin (so you'll need the jQuery library). Look at the "inline" example on this page: (click "demo" then "Show hidden modal content" link)
http://jquery.com/demo/thickbox/#sectiond-1
Initially, hide the OK
button and use a setTimeout()
to then show it after 10 seconds.
Upvotes: 2
Reputation: 92314
Not using alert
, You have to create your own (almost) modal dialog using JS and HTML with an OK button that is disabled, then use setTimeout
to enable it after ten seconds
Upvotes: 1