The window object in JavaScript has an event handler called onload. JavaScript alert() The alert() method in JavaScript is used to display a virtual alert box. The Window.alert() method displays an alert dialog with the optional specified content and an OK button.. Syntax window.alert(message);Parameters message Optional A string you want to display in the alert dialog, or, alternatively, an object that is converted into a string and displayed. The JavaScript alert, confirm and prompt methods display dialogue boxes that pop up and take focus away from the page and forces the user to read the message. Too many alerts and users will be upset. While using W3Schools, you agree to have read and accepted our, , ,