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 Overflow
🌐
W3Schools
w3schools.com › howto › howto_js_alert.asp
How To Create an Alert Message Box
Alert messages can be used to notify the user about something special: danger, success, information or warning.
🌐
W3Schools
w3schools.com › jsref › met_win_alert.asp
Window alert() Method
The alert() method displays an alert box with a message and an OK button. The alert() method is used when you want information to come through to the user.
🌐
University of Washington
washington.edu › accesscomputing › webd2 › student › unit5 › module2 › lesson1.html
Lesson 1: Using JavaScript to Show an Alert
However, we could trigger it using other events instead. For example, we might to display the alert only if a user clicks on a button. Try this: Remove the onload="showAlert()" attribute from the <body> element. Add the following HTML <button> element anywhere within the body of your web page:
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › API › Window › alert
Window: alert() method - Web APIs | MDN - Mozilla
window.alert() instructs the browser to display a dialog with an optional message, and to wait until the user dismisses the dialog.
🌐
GeeksforGeeks
geeksforgeeks.org › html › html-dom-window-alert-method
HTML DOM Window alert() Method - GeeksforGeeks
... <!DOCTYPE html> <html lang="en"> ... green;"> GeeksforGeeks </h1> <p> For displaying the alert message, double click the "Show Alert Message" button: </p> <button ondblclick="myalert()"> Show Alert Message </button> <script> ...
Published   July 11, 2025
🌐
Edureka
edureka.co › blog › javascript-alert
Alert() in JavaScript | How to Create an Alert Message Box | Edureka
February 25, 2025 - It displays a specified message along with an OK button and is generally used to make sure that the user gets the information. It returns a string which represents the text to display in the alert box. Let’s take an example and see how to create an alert in JavaScript: <!DOCTYPE html> <html> <head> <title> Alert() Method in JavaScript </title> <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" data-wp-preserve="<style> h1 { color: Blue; } h2 { font-family: Impact; } body { text-align: center; } </style>" data-mce-resize="false" data-mce-placeholder="1"
🌐
W3Schools
www-db.deis.unibo.it › courses › TW › DOCS › w3schools › howto › howto_js_alert.asp.html
How To Create an Alert Message Box
Indicates a warning that might need attention. <div class="alert"> <span class="closebtn" onclick="this.parentElement.style.display='none';">&times;</span> This is an alert box. </div> If you want the ability to close the alert message, add a <span> element with an onclick attribute that says ...
Find elsewhere
🌐
W3Schools
w3schools.com › JS › tryit.asp
W3Schools Tryit Editor - JavaScript Alert
❯Run Code Ctrl+Alt+R Save Code Ctrl+Alt+A Change Orientation Ctrl+Alt+O Change Theme Ctrl+Alt+D Go to Spaces Ctrl+Alt+P
🌐
Bootstrap
getbootstrap.com › docs › 4.0 › components › alerts
Alerts · Bootstrap
Skip to main content There's a newer version of Bootstrap! ... Provide contextual feedback messages for typical user actions with the handful of available and flexible alert messages. Alerts are available for any length of text, as well as an optional dismiss button. For proper styling, use one of the eight required contextual classes (e.g., .alert-success). For inline dismissal, use the alerts jQuery plugin.
🌐
YouTube
youtube.com › watch
How to Add an Alert Box to Your Websites with HTML & CSS - YouTube
View the SOURCE CODE 👇https://dcode.domenade.com/tutorials/how-to-add-an-alert-box-to-your-website-using-html-and-cssGoogle Material Symbols & Fonts 👇https...
Published   February 5, 2025
🌐
Uw
projects.accesscomputing.uw.edu › webd2 › student › unit5 › module2 › lesson1.html
Lesson 5.2.1: Using JavaScript to Show an Alert
However, we could trigger it using other events instead. For example, we might to display the alert only if a user clicks on a button. Try this: Remove the onload="showAlert()" attribute from the <body> element. Add the following HTML <button> element anywhere within the body of your web page:
🌐
Codecademy
codecademy.com › forum_questions › 512d28a06918338f2300e9ea
How to make a html button clickable and to show alert on it ? | Codecademy
<script> function clickAlert() { alert("Alert!"); } </script> <input type="button" onclick="clickAlert()" value="Click-2-Alert">
🌐
TutorialsPoint
tutorialspoint.com › how-to-create-alert-messages-with-css
How to create alert messages with CSS?
To create alert messages with CSS, the code is as follows − · <!DOCTYPE html> <html> <head> <style> body{ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; } .alertMessage { padding: 20px; background-color: #f44336; color: white; font-size: 20px; } .close{ margin-left: 15px; color: white; font-weight: bold; float: right; font-size: 22px; line-height: 20px; cursor: pointer; transition: 0.3s; } .close:hover { color: black; } </style> </head> <body> <h1>Alert Message Example</h1> <div class="alertMessage"> <span class="close" onclick="this.parentElement.style.display='none';">×</span> <strong>This cannot be revered!</strong> Your account will be deleted.
🌐
Quackit
quackit.com › javascript › javascript_alert_box.cfm
JavaScript Alert Box
The JavaScript alert box is useful for alerting your users to something important. When a JavaScript alert box is triggered, a small box will pop up and display the text that you specify in your JavaScript code. You create a JavaScript alert box by calling the built-in JavaScript alert() function. ...
🌐
Tutorialdeep
tutorialdeep.com › knowhow › html faqs › how to create jquery alert message box in html
How to Create or Add jQuery Alert Message Box in HTML
April 4, 2021 - In this tutorial, learn how to create or add a jQuery alert message box in HTML content. The short answer is to use the jQuery alert() and pass the content as t