开发者

'Yes', 'No', and Cancel with JavaScript confirm function

I am familiar with the basic JavaScript confirm function. I want to take one step further: instead of having a message box pop up with the options of "OK" and "Cancel", I would like to add three options and change the dialog so that the three choices read "Confirm", "Deny", and "cancel"开发者_运维技巧. A "Confirm" or "Deny" choice would each call a different function. Any suggestions on how to do this?

I am not using JQuery or any other library, and i really don't want to use any if I can help it, as it's just this one function. Any help would be appreciated.


You will want to look into making a custom dialog from a div, and assign click events to the buttons. You can't modify the browser's standard dialogs without using VBScript which is IE only.

The fact that you don't want to use JQuery is quite silly. It's 31k and the best thing to ever happen to JavaScript.

If you want to avoid JQueryUI, you can create a dialog yourself very easily. Here's a tutorial to get you started: http://www.queness.com/post/1696/create-a-beautiful-looking-custom-dialog-box-with-jquery-and-css3


AFAIK, you cannot change the button prompt strings with just using pure JS. It has to be 'OK' and 'Cancel'.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜