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
๐ŸŒ
MDN Web Docs
developer.mozilla.org โ€บ en-US โ€บ docs โ€บ Web โ€บ API โ€บ Window โ€บ alert
Window: alert() method - Web APIs | MDN
October 4, 2023 - window.alert() instructs the browser to display a dialog with an optional message, and to wait until the user dismisses the dialog.
๐ŸŒ
W3Schools
w3schools.com โ€บ jsref โ€บ met_win_alert.asp
Window alert() Method
The alert box takes the focus away from the current window, and forces the user to read the message. Do not overuse this method. It prevents the user from accessing other parts of the page until the alert box is closed.
๐ŸŒ
University of Washington
washington.edu โ€บ accesscomputing โ€บ webd2 โ€บ student โ€บ unit5 โ€บ module2 โ€บ lesson1.html
Lesson 1: Using JavaScript to Show an Alert
Then test it to be sure it works. So far in this lesson, we have called the showAlert() function when the body of the web page is loaded. 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.
๐ŸŒ
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
๐ŸŒ
W3Schools
w3schools.com โ€บ howto โ€บ howto_js_alert.asp
How To Create an Alert Message Box
Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, Python, PHP, Bootstrap, Java, XML and more.
๐ŸŒ
TutorialsTeacher
tutorialsteacher.com โ€บ javascript โ€บ display-popup-message-in-javascript
JavaScript Message Boxes: alert(), confirm(), prompt()
The alert() function displays a message to the user to display some information to users. This alert box will have the OK button to close the alert box. ... The alert() function takes a paramter of any type e.g., string, number, boolean etc.
๐ŸŒ
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.
Find elsewhere
๐ŸŒ
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. ...
๐ŸŒ
Educative
educative.io โ€บ answers โ€บ how-to-use-the-alert-method-in-javascript
How to use the alert() method in JavaScript
An alert message can simply be shown when the HTML file runs, before the user accesses any other elements on the page.
๐ŸŒ
W3Schools
w3schools.com โ€บ js โ€บ js_popup.asp
JavaScript Popup Boxes
JS Examples JS HTML DOM JS HTML Input JS HTML Objects JS HTML Events JS Browser JS Editor JS Exercises JS Quiz JS Website JS Syllabus JS Study Plan JS Interview Prep JS Bootcamp JS Certificate JS Reference ... An alert box is often used if you want to make sure information comes through to the user.
๐ŸŒ
Uw
projects.accesscomputing.uw.edu โ€บ webd2 โ€บ student โ€บ unit5 โ€บ module2 โ€บ lesson1.html
Lesson 5.2.1: Using JavaScript to Show an Alert
Then test it to be sure it works. So far in this lesson, we have called the showAlert() function when the body of the web page is loaded. 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.
๐ŸŒ
JavaScript.info
javascript.info โ€บ tutorial โ€บ the javascript language โ€บ javascript fundamentals
Interaction: alert, prompt, confirm
There are other ways to show nicer windows and richer interaction with the visitor, but if โ€œbells and whistlesโ€ do not matter much, these methods work just fine. ... Create a web-page that asks for a name and outputs it. ... <!DOCTYPE html> <html> <body> <script> 'use strict'; let name = prompt("What is your name?", ""); alert(name); </script> </body> </html>
๐ŸŒ
Team Treehouse
teamtreehouse.com โ€บ community โ€บ how-do-i-call-an-alert-to-a-javascript-tag
how do I call an alert(); to a javascript tag (Example) | Treehouse Community
April 9, 2017 - A task has asked me to write a program inside a script tag that would open a alert(); that said warning!. I attempted the code and the box with the message appeared now it says my script tag no longer works. ... <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>JavaScript Basics</title> </head> <body> <script src="scripts.js"></script> <script> alert("Warning!"); </script> </body> </html>
๐ŸŒ
Stack Overflow
stackoverflow.com โ€บ questions โ€บ 48105950 โ€บ how-do-i-display-a-alert-on-a-website
javascript - How do I display a alert on a website? - Stack Overflow
This is really easy to do and is recommended especially if you are just starting. An example of implementing this on your HTML website: <script type="text/javascript"> alert('My message goes here'); </script>
๐ŸŒ
HTML Code Generator
html-code-generator.com โ€บ javascript โ€บ alert-message
JavaScript Alert Message Code Generator | Popup Alerts
JavaScript Alert Message Generator. Button On click Alert Message. Window Onload Alert(). Body Onload Alert. Alert HTML codes or text
๐ŸŒ
Javatpoint
javatpoint.com โ€บ javascript-alert
JavaScript alert() - javatpoint
JavaScript alert() with javascript tutorial, introduction, javascript oops, application of javascript, loop, variable, objects, map, typedarray etc.
๐ŸŒ
SheCodes
shecodes.io โ€บ athena โ€บ 12892-how-to-display-an-alert-message-in-javascript
[JavaScript] - How to display an alert message in | SheCodes
Learn how to use the alert() function to display pop-up messages in JavaScript with this simple example code snippet.
๐ŸŒ
Js
alertbox.js.org
AlertBox - A simple, beautiful, responsive, easy to use, customizable text for JavaScript's Alert Box.
alertbox.render({ alertIcon: 'warning', title: 'Thank You!', message: 'AlertBox Popup Message', btnTitle: 'Ok', border:true }); ... alertbox.render({ alertIcon: 'info', title: 'Thank You!', message: 'AlertBox Popup Message', btnTitle: 'Ok', border:true });
๐ŸŒ
W3Schools
w3schools.com โ€บ js โ€บ tryit.asp
W3Schools Tryit Editor - JavaScript Alert
The W3Schools online code editor allows you to edit code and view the result in your browser