0

I have the following statement:

alert("Testing 123\n\n Testing 231");


I wanted to add a '< hr >'-liked tag between both \n\n. Is there any method to make a line in between?
Pradeep Simha
  • 17,683
  • 18
  • 56
  • 107
Stevey
  • 11
  • 1

2 Answers2

1

You cannot add HTML code into an alert box, unfortunately.

However, you could attempt to simulate one if you really want a horizontal line in there; something like this would do the trick:

alert("Testing 123\n________________________\n Testing 231");

I wouldn't really recommend this though because getting the _____ across the entire alert box wouldn't be practical to do, since the width of an alert box is relative to the particular browser, so there isn't really any uniformity.

Nick Zuber
  • 5,467
  • 3
  • 24
  • 48
  • He's not asking to add html code, he's asking to have a similar effect as a
    tag with other means.
    – Bimde Nov 26 '15 at 04:19
  • thank you for this and i do understand the width of an alert box is relatively linked to the browser,that's why i'm looking for another way to do it – Stevey Nov 26 '15 at 04:27
0

No, you cannot add html tags in the browser alert function.

BUT you can do this IF you are using jQuery UI.

$("<div>Testing 123<br/><hr/><br/>Testing 231</div>").dialog();
Community
  • 1
  • 1