Hi Everybody,

I was wondering if any of you know about alert window textual content. I am trying to disable where it says "from "xxxx.com" " line in the heading of the alert window? Also is there any way to customize it? For example, can I add a photo or different text?

Thank you,
w33n

Dani AI

Generated

Short answer for : you cannot remove or style the browser-supplied "from 'xxxx.com'" text in the native alert/confirm dialog. Those dialogs are part of the browser chrome (not page content) and are intentionally controlled by the browser for security and consistency. See the official docs for the native API: Window.alert documentation.

For control over visuals and content (images, custom headings, branding), replace the native dialog with a DOM-based modal. As hinted, libraries exist that do this; you can also build a lightweight custom modal. Important notes when doing so: native alert()/confirm() are synchronous and block script execution, while custom modals are asynchronous (use callbacks or promises), and you must implement proper accessibility and focus management.

Minimal accessible modal structure (skeleton):

<div class="modal" role="dialog" aria-modal="true" aria-label="Site alert">
  <div class="modal-content">
    <button class="close" aria-label="Close">Close</button>
    <img src="logo.png" alt="Site logo">
    <p>Message text here</p>
    <button class="ok">OK</button>
  </div>
</div>

Checklist before shipping: trap focus inside the dialog, return focus to the triggering element on close, support keyboard (Esc, Enter), prevent background scrolling while open, and verify screen-reader behavior. For accessibility guidance see the WAI-ARIA dialog patterns: Dialog (Modal) — WAI-ARIA Authoring Practices.

Recommended Answers

All 2 Replies

Alert boxes can't be customised too much. I would suggest looking into some of the javascript libaries that do that for you. SweetAlert is one I've used but there are others. You can vary the text and add images into the message.

Cool, Thank you for the feedback.

B

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.