[英]How to display animating countdown in confirmation box in javascript
All I wanna be able to do is to change the confirm message after its being displayed. 我想要做的就是在显示确认消息后对其进行更改。
In this particular example I wanna give a 10 second time frame to the user to decide whether to do something or cancel it. 在这个特定的示例中,我想给用户10秒钟的时间来决定是做某件事还是取消某件事。 So upon the display of the confirm popup then start counting down 10, 9 , 8 , ... 0 and once the time elapsed it continues the execution with the "do something" part (as if ok button was pressed)
因此,在显示确认弹出窗口时,然后开始递减10、9、8,... 0,一旦经过时间,它将继续执行“做某事”部分(好像按下了确定按钮)。
Is it possible to implement such a thing with pure javascript or I have to libraries for that? 是否可以使用纯JavaScript来实现这种功能,或者我必须为此编写库?
I am not looking for anything fancy though. 我虽然没有任何花哨的东西。
You can't do this with the normal confirm
. 您不能使用常规
confirm
来执行此操作。 With confirm
, the program execution waits until the user selects OK or Cancel. 使用
confirm
,程序执行将一直等到用户选择“确定”或“取消”。
Instead, you will have to generate that confirmation box yourself (or with a JS library). 相反,您必须自己(或使用JS库)生成该确认框。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.