+ 1

why cant i use text formatting tags while using alert function ?

for example document.write ("<b> hello world </b> "); this works fine & makes text Bold but alert ("<b> hello world </b>"); returns an alert box with all the text inside "" with tags and text isnt formatted

25th Dec 2017, 4:18 AM
Rahul
3 ответов
+ 4
Document.write basically inserts the desired string into the HTML, making any tags take effect. Alert, however, just prints the string in an alert box. I do not think the alert boxes can have styling added to them.
25th Dec 2017, 4:54 AM
Spencer
+ 3
@Spencer is correct. The alert dialog box can only show plain text. If you would like formatting in your text in an alternative modal dialog box, you could use JavaScript and HTML to simulate modal behavior. A good example can be seen in the Bootstrap documentation for their version of the Modal behavior. - https://v4-alpha.getbootstrap.com/components/modal/#live-demo
25th Dec 2017, 5:06 AM
David Carroll
David Carroll - avatar
+ 1
thank You both
4th Jan 2018, 2:28 AM
Rahul