Format the text in JavaScript alert box

前端 未结 7 2309
广开言路
广开言路 2020-12-09 02:19

How can I format the text in a JavaScript alert box? I need a word in the text to be underlined.

7条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-09 02:40

    Needed this badly, but none of the answers were particular helpful. As two answers suggest the solution is to use unicode, but you have to do this properly! I also wanted a more reuseable solution where I not needed to reinvent the wheel each and every time. So came up with this small javascript function for convenience.

    alert('Really need to alert some '+toUnicodeVariant('underlined', 'bold sans', 'underline')+' text');

    Should produce something like this in all major browsers (try run the code snippet above) :

提交回复
热议问题