javascript 自定义 JS 提示弹出窗口

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12458488/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 16:15:24  来源:igfitidea点击:

Custom JS Prompt Popup

javascriptjqueryprompt

提问by David Gard

I'm looking for a way to customise the JS prompt popup so that I can give the user the options that I want them to have -

我正在寻找一种自定义 JS 提示弹出窗口的方法,以便我可以为用户提供我希望他们拥有的选项 -

  1. Change - Take the value from the prompt box and change the value that was checked to initiate the prompt in the first place.
  2. Continue - Don't care, continue with the original value.
  3. Cancel - Forget this, just get rid of the box.
  1. 更改 - 从提示框中获取值并更改首先选中以启动提示的值。
  2. 继续 - 不在乎,继续使用原始值。
  3. 取消 - 忘记这一点,只需摆脱盒子即可。

Options 1 & 3 are available by default (albeit with option 1 being called 'Ok'), but I am unaware of a way to manipulate the prompt to offer a 3rd option.

默认情况下,选项 1 和 3 可用(尽管选项 1 被称为“确定”),但我不知道有什么方法可以操纵提示以提供第三个选项。

I'm guessing that this cannot be done through JS, so are there any jQuery plugins that may help me? Thanks.

我猜这不能通过 JS 完成,那么是否有任何 jQuery 插件可以帮助我?谢谢。

回答by Armel Larcier

You're right, you can't customize the browser's prompt box: Here is a jquery ui plugin that will help you make modal windows:

你说得对,你不能自定义浏览器的提示框:这是一个jquery ui插件,可以帮助你制作模态窗口:

http://docs.jquery.com/UI/Dialog/dialog#options

http://docs.jquery.com/UI/Dialog/dialog#options

You might also use and customize (extend) this:

您还可以使用和自定义(扩展)这个:

http://labs.abeautifulsite.net/archived/jquery-alerts/demo/

http://labs.abeautifulsite.net/archived/jquery-alerts/demo/

回答by Zathrus Writer

jQuery UI has a dialog componentthat can be used for this.

jQuery UI 有一个对话框组件可用于此目的。

If you're looking for a less bloated solution, a Google Searchcomes up with many reusable results.

如果您正在寻找一种不那么臃肿的解决方案,Google 搜索会提供许多可重复使用的结果。

回答by Ricardo Binns

Check this plugin, i think you can change everything u need: jAlert

检查这个插件,我想你可以改变你需要的一切:jAlert

回答by Lazadon

https://github.com/bmmage/customAlert

https://github.com/bmmage/customAlert

jquery plugin that allows for customization of Alert windows and slide down alert boxes.

jquery 插件,允许自定义警报窗口和向下滑动警报框。