How to create TRULY modal alerts/confirms in Javascript?

后端 未结 2 1094
别那么骄傲
别那么骄傲 2021-01-24 05:15

I am sifting through prompt() and confirm() replacements for JavaScript. I need to create a couple of confirm()s and alert()s that have three or more o

相关标签:
2条回答
  • 2021-01-24 05:39

    Most JavaScript frameworks that have UI components have some kind of dialog that will provide callbacks. Check out jQuery UI, for example: http://jqueryui.com/demos/dialog/

    I've used it in multiple projects to do exactly what you're describing.

    Edit: I was hoping to suggest a workaround. Unfortunately JavaScript does not include methods to override and add additional buttons or options to the default browser-based Alert(), Confirm(), or Prompt() dialogs.

    0 讨论(0)
  • 2021-01-24 06:00

    Both IE and Firefox 3 have a showModalDialog method which would allow you to display an entire web page modally. However for a truely cross-browser solution you can't use that.

    Many of the popular frameworks provide a mechanism to do it by displaying a HTML element and disabling access to the rest of the web page whilst the element is displayed.

    0 讨论(0)
提交回复
热议问题