+ 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
3 Answers
+ 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.
+ 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
+ 1
thank You both