4

in javascript, how to make alert bold n use h1 to h5 headers? Is this possible or simply plain alert is option?

how to include bold and h1 to this alert?



function onlooad()
{
    alert("wssup??");

}

SilentGhost
  • 287,765
  • 61
  • 300
  • 288
Abhilash Muthuraj
  • 1,878
  • 8
  • 29
  • 48

5 Answers5

11

You can not use HTML in alert(). For that you need to use window.open() or some custom code like this:
http://docs.jquery.com/UI/Dialog

  • Hi is jquery on top of javascript, i know little javascript, is it worth learning jquery?? Is it easy to use and faster in execution? – Abhilash Muthuraj Apr 16 '10 at 11:41
  • @abhilash M You might want to start here http://stackoverflow.com/questions/2628672/what-every-javascript-programmer-should-know – David Apr 16 '10 at 11:46
3

As far as I know, this is impossible.

Evgeny Shadchnev
  • 7,112
  • 4
  • 26
  • 30
2

You can use custom elements that act like alert boxes. Check this one out

jQuery Impromptu

darksoulsong
  • 11,559
  • 13
  • 42
  • 82
rahul
  • 179,909
  • 49
  • 229
  • 260
1

Javascript alert is limited in terms of formatting because it does not recognise HTML markup. If this is important, consider an in-page alternative. A quick web search turned up the following:

http://www.jondavis.net/codeprojects/jqalert/

spender
  • 112,247
  • 30
  • 221
  • 334
  • spender what can be a solution to [this question](http://stackoverflow.com/questions/9347654/combo-box-is-getting-vanished-when-an-alert-is-coming) – Tom Feb 19 '12 at 08:58
0

Sorry, but in JavaScript, you can only use plaintext alerts. Now, you can use \n for a newline, by the way, but the alert() function only allows plaintext. Again, sorry.

Sammy
  • 1
  • 1