There is a load event, which will fire AFTER the page is loaded. You can listen to the event:
window.addEventListener('load', function() {
console.log('All assets are loaded');
alert ("This is an alert MSG");
})
Answer from Raptor on Stack OverflowVideos
There is a load event, which will fire AFTER the page is loaded. You can listen to the event:
window.addEventListener('load', function() {
console.log('All assets are loaded');
alert ("This is an alert MSG");
})
You can use setTimeout() for this
<html>
<head>
<title>Hello, World !</title>
</head>
<body>
<h1>I am learning JavaScript.</h1>
<div id="Content">
<p>This is a paragraph tag. Here the content of html.</p>
</div>
<script>
setTimeout(()=>{
alert(" This is alert message.")
},2000)
</script>
</body>
</html>
You can use all Unicode characters and the escape characters \n and \t. An example:
document.getElementById("test").onclick = function() {
alert(
'This is an alert with basic formatting\n\n'
+ "\t• list item 1\n"
+ '\t• list item 2\n'
+ '\t• list item 3\n\n'
+ '▬▬▬▬▬▬▬▬▬ஜ۩۞۩ஜ▬▬▬▬▬▬▬▬▬\n\n'
+ 'Simple table\n\n'
+ 'Char\t| Result\n'
+ '\\n\t| line break\n'
+ '\\t\t| tab space'
);
}
<!DOCTYPE html>
<title>Alert formatting</title>
<meta charset=utf-8>
<button id=test>Click</button>
Result in Firefox:

You get the same look in almost all browsers.
alert() is a method of the window object that cannot interpret HTML tags
You look like you are trying to use Bootstrap's 'alert' classes (e.g. 'success'). http://getbootstrap.com/components/#alerts
The only way to make that a semantic element like <alert /> that I know of is something like AngularJS: http://angular-ui.github.io/bootstrap/#/alert
In this case, it is all styled by Bootstrap, or whatever Bootstrap theme you are using.
First there is not an HTML tag alert. you can create an alert with javascript.
You cannot add style to an alert as it is produced by the browser by default.
Have a look to this post: How do I style the alert box with CSS?