Which JavaScript method should display a welcome message when the site loads?

Prepare for the uCertify CIW Advanced HTML5 and CSS3 Specialist Exam. Dive into essential topics with flashcards and multiple-choice questions. Enhance your understanding with hints and explanations for each question. Pass your exam confidently!

Multiple Choice

Which JavaScript method should display a welcome message when the site loads?

Showing a welcome message when the page loads is best done with a simple modal dialog that the user must acknowledge. The alert method does exactly this: it displays a message in a pop-up dialog with an OK button and blocks further interaction until the user dismisses it. That immediacy and visibility make it ideal for a welcome note that you want noticed right away as the site loads.

Logging to the console wouldn’t reach the user unless they open developer tools, so it wouldn’t serve as a visible welcome message. A confirm dialog provides OK and Cancel options, which is for a decision, not just a notification. A prompt asks for text input, which isn’t appropriate for a simple greeting.

If you want the message to appear automatically on load, call the alert in a script that runs after the page has loaded, such as in a script tag at the end of the body or inside a DOMContentLoaded handler.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy