+ 12

How to format text in JavaScript alert.

alert("this is the formatted text"); i want the text in the alert to be of color green ,justified and bold.

16th Feb 2018, 9:27 AM
Christine
Christine - avatar
9 Answers
+ 6
oh come on guys atleast there must be some thing i can do maybe to create functions that return the formated text
17th Feb 2018, 11:49 AM
Christine
Christine - avatar
+ 5
You can't, its impossible. You don't get control over the OS styling of a browsers alert window. Im sure there would be a way using javascript and a ton of code but it wouldn't work for every browser and operating system and would be buggy as heck. You are best to draw your own alert modal window and style that instead. I really like using sweet alert, have a look into that.
16th Feb 2018, 9:49 AM
ihateonions
+ 5
A modal box gives you creative control. https://code.sololearn.com/WFC0N5D1V2S7/?ref=app
2nd Mar 2018, 1:20 PM
Tigress
Tigress - avatar
+ 2
you can't do it
16th Feb 2018, 2:48 PM
Leo PháșĄm
Leo PháșĄm - avatar
+ 2
meh, sorry for disspointing but you still can't
24th Feb 2018, 5:33 AM
Blizz
Blizz - avatar
+ 2
alert prompt and confirm we can't style
27th Feb 2018, 10:38 PM
Anna Hyrylo
Anna Hyrylo - avatar
+ 1
you can use sweet alert library, and then modify it
25th Feb 2018, 5:15 PM
Rolando San Miguel
Rolando San Miguel - avatar
+ 1
you can use sweet alert, and then modify it. here is the link: https://lipis.github.io/bootstrap-sweetalert/
25th Feb 2018, 5:17 PM
Rolando San Miguel
Rolando San Miguel - avatar
+ 1
I have a new solution. You must do your own div element and button to set their visibility. Check this out!!||| https://code.sololearn.com/WRv8dD8M7j9M/?ref=app
5th Mar 2018, 2:16 PM
Blizz
Blizz - avatar