2

So say I have the following code:

window.prompt('Redirecting');
location.href = '/';

(I know this isn't useful code, but wait one sec) I can't figure out how to make it so that prompt doesn't 'freeze' the whole browser so that the redirect is forced to happen. So that in essence what I want is the prompt to come up and immediately for the page to redirect. (without user pressing anything)

I can't seem to find any documentation on how to have a timer on prompt to stop it after a while and/or to stop it from some other method. Anyone have any thoughts?

4

2 回答 2

1

You can not have a timer to close a prompt, alert, confirm, etc.

If you want to do something like that you are going to have to build something using layers in JavaScript. Look at libraries like jQuery UI dialog, YUI's, dojos, or any other library out there.

于 2013-02-04T15:58:48.863 回答
0

How alert, prompt, etc behave is up to the browser. Mostly, they are fully modal, so they block all input. I'd suggest a framework such as FancyBox to show a popup that isn't modal and isn't under the browser's control.

于 2013-02-04T16:01:11.910 回答