Can we give background color to an alertbox in a javascript program using css?If so how is it possible. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 6

Can we give background color to an alertbox in a javascript program using css?If so how is it possible.

26th Nov 2016, 2:48 PM
Sreerag V S
Sreerag V S - avatar
4 Answers
+ 6
Thanks all for helping
26th Nov 2016, 4:30 PM
Sreerag V S
Sreerag V S - avatar
+ 4
the answer is yes...and no.... there is the alert() which simply alerts you and is supplied by javascript, but the color of the box cannot be changed, buttons cannot be change, 'about:blank' message you see on top, also can not be changed however you can use jquery to create and customize the colors, buttons, just about anything i will post a code in a bit demonstrating the two boxes edit look in my codes
26th Nov 2016, 2:53 PM
Burey
Burey - avatar
0
Ive never heard of this but i looked it up and some say its possible and some say its not.... But heres a link that maybe able to help you out: http://stackoverflow.com/questions/7853130/how-to-change-the-style-of-alert-box
26th Nov 2016, 4:29 PM
Aquarius
Aquarius - avatar
0
You can't really, and even if you could it'd be browser dependent. I'd create a new element, pushed to the top using: position: fixed and z-index: 100 to create a dialog box that is purely an element. Then modify the contents of it with JS via innerHTML or jquery.
27th Nov 2016, 9:10 AM
Jared Allard
Jared Allard - avatar