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
  • 307,395
  • 66
  • 306
  • 293
Abhilash Muthuraj
  • 2,008
  • 9
  • 34
  • 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,320
  • 4
  • 27
  • 30
2

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

jQuery Impromptu

darksoulsong
  • 13,988
  • 14
  • 47
  • 90
rahul
  • 184,426
  • 49
  • 232
  • 263
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
  • 117,338
  • 33
  • 229
  • 351
  • 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