Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to style default confirm box with only css?

Tags:

css

confirm

I would like to style standard window.confirm without using any additional JavaScript code, only with CSS. Is it even possible? And if it is, how can I do it?

like image 255
opportunato Avatar asked May 31 '11 08:05

opportunato


3 Answers

It is not possible. This window is displayed by the browser using the platform's UI kit. It's not in the DOM, not visible from the CSS or Javascript, there's nothing you can do.

However, some very simple jQuery code can do the trick. How about $('a').confirm(); ?

like image 192
solendil Avatar answered Nov 10 '22 16:11

solendil


confirm(); alerts cannot be styled, they are generic to the browser. If you want to style an alert, try alternatives such as boxy, or the jQuery dialog box.

Here is a tutorial about how a custom confirm alert can be created in jQuery and styled with CSS.

like image 14
shearnonsense Avatar answered Nov 10 '22 17:11

shearnonsense


This is a very old question. But I felt the need to pass this info here. I noticed that you can "style" the confirm with special characters, such as \n, \t, \r, ... so on.

like image 2
Mikko-Pentti Einari Eronen Avatar answered Nov 10 '22 17:11

Mikko-Pentti Einari Eronen