Your question seems to be based on a false premise ("The javascript alert box always shows up at the top of the page"). Where a Javascript alert() box appears is down to the browser: from a quick test:

  • Chrome positions the alert box centred, at the top of the browser window:

  • IE11 positions the alert box in the centre of the screen (both vertically and horizontally), irrespective of where the browser window is:

This lack of control of the position and appearance of the built-in alert/confirm dialogs of Javascript is why many implement alerts using JS/CSS.

Answer from TripeHound on Stack Exchange
๐ŸŒ
W3Schools
w3schools.com โ€บ js โ€บ js_popup.asp
JavaScript Popup Boxes
The window.alert() method can be written without the window prefix. ... A confirm box is often used if you want the user to verify or accept something.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ javascript โ€บ how-to-edit-a-javascript-alert-box-title
How to Edit a JavaScript Alert Box Title ? - GeeksforGeeks
August 5, 2025 - We can't directly modify the title of the alert box because the title is controlled by the browser and cannot be changed by JavaScript.
๐ŸŒ
MDN Web Docs
developer.mozilla.org โ€บ en-US โ€บ docs โ€บ Web โ€บ API โ€บ Window โ€บ alert
Window: alert() method - Web APIs | MDN
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() method displays an alert box with a message and an OK button.
Find elsewhere
๐ŸŒ
Js
alertbox.js.org
AlertBox - A simple, beautiful, responsive, easy to use, customizable text for JavaScript's Alert Box.
AlertBox - A simple, beautiful, responsive, easy to use, customizable text for JavaScript's Alert Box.
๐ŸŒ
Bootstrap
getbootstrap.com โ€บ docs โ€บ 5.0 โ€บ components โ€บ alerts
Alerts ยท Bootstrap v5.0
Alerts are available for any length of text, as well as an optional close button. For proper styling, use one of the eight required contextual classes (e.g., .alert-success). For inline dismissal, use the alerts JavaScript plugin.
๐ŸŒ
Penn State
accessibility.psu.edu โ€บ scripts โ€บ alertboxes
Accessibility at Penn State | Alert Boxes
September 15, 2018 - The link includes an onClick event which opens an alertbox when it is clicked on or the user clicks the ENTER button when the cursor is at the link. This works because browsers add a keyboard interpretation and also because the A tag includes a dummy href=โ€#โ€ URL. This allows all devices to recognize the link as a link. Note: When using JavaScript click events, it is important to verify that they also work with a keyboard or add a keyboard version.
๐ŸŒ
Quackit
quackit.com โ€บ javascript โ€บ javascript_alert_box.cfm
JavaScript Alert Box
When a JavaScript alert box is triggered, a small box will pop up and display the text that you specify in your JavaScript code.
๐ŸŒ
Adobe
acrobatusers.com โ€บ tutorials โ€บ popup_windows_part1
The alert box: Part 1 of 5 on popup windows
June 7, 2008 - It displays short text messages (errors, warnings, etc.) and asks yes/no questions. Try it out by running the following code in the JavaScript Console. ... This statement displays a Popup Window with the words โ€œHello Worldโ€ and an info Icon (Figure 1). Figure 1 ย– Alert Box used as an information popup
๐ŸŒ
Snap! Forum
forum.snap.berkeley.edu โ€บ advanced topics
How can I make a custom javascript alert() box like the one in the snap website? - Advanced Topics - Snap! Forum
July 31, 2022 - Ik this is offtopic but I'm making a website and I want to make a custom alert box like the one in the snap website ex:
๐ŸŒ
Telerik
telerik.com โ€บ blogs โ€บ how-to-do-javascript-alerts-without-being-a-jerk
How To Do JavaScript Alerts Without Being A Jerk
May 27, 2021 - The ONLY thing I took from that tutorial was that I could create a modal window in JavaScript with virtually zero effort on my part. What transpired next was several years of flagrant "alert abuse". I put alerts everywhere. Alerts, prompts, confirms - you name it.
๐ŸŒ
SitePoint
sitepoint.com โ€บ javascript
Yes / No Confirm Alert Box - JavaScript - SitePoint Forums | Web Development & Design Community
December 30, 2005 - Is there a predefined way to display a Message to the user giving them a Yes and No button that is as easy to code as Alert in JavaScript? What I what to do is provide the user a confirm box after the click the delete bโ€ฆ
๐ŸŒ
TutorialsTeacher
tutorialsteacher.com โ€บ javascript โ€บ display-popup-message-in-javascript
JavaScript Message Boxes: alert(), confirm(), prompt()
JavaScript provides built-in global functions to display popup message boxes for different purposes. alert(message): Display a popup box with the specified message with the OK button.
๐ŸŒ
Uw
projects.accesscomputing.uw.edu โ€บ webd2 โ€บ student โ€บ unit5 โ€บ module2 โ€บ lesson1.html
Using JavaScript to Show an Alert
Most programming or scripting languages ... useful function that's native to JavaScript is the alert() function. This function will display text in a dialog box that pops up on the screen....