You can use all Unicode characters and the escape characters \n
and \t
. An example:
document.getElementById("test").onclick = function() {_x000D_
alert(_x000D_
'This is an alert with basic formatting\n\n' _x000D_
+ "\t• list item 1\n" _x000D_
+ '\t• list item 2\n' _x000D_
+ '\t• list item 3\n\n' _x000D_
+ '???????????????????????\n\n' _x000D_
+ 'Simple table\n\n' _x000D_
+ 'Char\t| Result\n' _x000D_
+ '\\n\t| line break\n' _x000D_
+ '\\t\t| tab space'_x000D_
);_x000D_
}
_x000D_
<!DOCTYPE html>_x000D_
<title>Alert formatting</title>_x000D_
<meta charset=utf-8>_x000D_
<button id=test>Click</button>
_x000D_
Result in Firefox:
You get the same look in almost all browsers.