HTML - Alert Box when loading page

Jonathan Gurebo picture Jonathan Gurebo · Feb 14, 2013 · Viewed 149.6k times · Source

i'm using HTML code and i wan't to show un Alert Message or alert box, i don't know what it is called, but a message with a "OK" button.

i want to show this alert when the page is loaded.

How do i do this?

And how to do this with a title in the Alert box?

Do I need JavaScript? if no, How to do this without javascript?

Jonathan

Answer

Adam Plocher picture Adam Plocher · Feb 14, 2013

Yes you need javascript. The simplest way is to just put this at the bottom of your HTML page:

<script type="text/javascript">
alert("Hello world");
</script>

There are more preferred methods, like using jQuery's ready function, but this method will work.