ert() - Web APIs - MDN Web Docs - Mozilla
Có thể bạn quan tâm
- Skip to main content
- Skip to search
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
- Learn more
- See full compatibility
- Report feedback
window.alert() instructs the browser to display a dialog with an optional message, and to wait until the user dismisses the dialog.
Under some conditions — for example, when the user switches tabs — the browser may not actually display a dialog, or may not wait for the user to dismiss the dialog.
In this article
- Syntax
- Examples
- Notes
- Specifications
- Browser compatibility
- See also
Syntax
jsalert() alert(message)Parameters
message OptionalA string you want to display in the alert dialog, or, alternatively, an object that is converted into a string and displayed.
Return value
None (undefined).
Examples
jswindow.alert("Hello world!"); alert("Hello world!");Both produce:

Notes
The alert dialog should be used for messages which do not require any response on the part of the user, other than the acknowledgement of the message.
Dialog boxes are modal windows - they prevent the user from accessing the rest of the program's interface until the dialog box is closed. For this reason, you should not overuse any function that creates a dialog box (or modal window).
Alternatively <dialog> element can be used to display alerts.
Specifications
| Specification |
|---|
| HTML# dom-alert-dev |
Browser compatibility
See also
- <dialog> element
- confirm
- prompt
Help improve MDN
Was this page helpful to you? Yes No Learn how to contributeThis page was last modified on Oct 4, 2023 by MDN contributors.
View this page on GitHub • Report a problem with this content Filter sidebar- Window
- Instance properties
- caches
- closed
- cookieStore
- credentialless Experimental
- crossOriginIsolated
- crypto
- customElements
- devicePixelRatio
- document
- documentPictureInPicture Experimental
- event Deprecated
- external Deprecated
- fence Experimental
- frameElement
- frames
- fullScreen Non-standard
- history
- indexedDB
- innerHeight
- innerWidth
- isSecureContext
- launchQueue Experimental
- length
- localStorage
- location
- locationbar
- menubar
- mozInnerScreenX Non-standard
- mozInnerScreenY Non-standard
- name
- navigation
- navigator
- opener
- orientation Deprecated
- origin
- originAgentCluster
- outerHeight
- outerWidth
- parent
- performance
- personalbar
- scheduler
- screen
- screenLeft
- screenTop
- screenX
- screenY
- scrollbars
- scrollMaxX Non-standard
- scrollMaxY Non-standard
- scrollX
- scrollY
- self
- sessionStorage
- sharedStorage Deprecated
- speechSynthesis
- status Deprecated
- statusbar
- toolbar
- top
- trustedTypes
- viewport Experimental
- visualViewport
- window
- Instance methods
- alert()
- atob()
- blur() Deprecated
- btoa()
- cancelAnimationFrame()
- cancelIdleCallback()
- captureEvents() Deprecated
- clearImmediate() Non-standard Deprecated
- clearInterval()
- clearTimeout()
- close()
- confirm()
- createImageBitmap()
- dump() Non-standard
- fetch()
- fetchLater() Experimental
- find() Non-standard
- focus()
- getComputedStyle()
- getDefaultComputedStyle() Non-standard
- getScreenDetails() Experimental
- getSelection()
- matchMedia()
- moveBy()
- moveTo()
- open()
- postMessage()
- print()
- prompt()
- queryLocalFonts() Experimental
- queueMicrotask()
- releaseEvents() Deprecated
- reportError()
- requestAnimationFrame()
- requestFileSystem() Non-standard Deprecated
- requestIdleCallback()
- resizeBy()
- resizeTo()
- scroll()
- scrollBy()
- scrollByLines() Non-standard
- scrollByPages() Non-standard
- scrollTo()
- setImmediate() Non-standard Deprecated
- setInterval()
- setResizable() Non-standard Deprecated
- setTimeout()
- showDirectoryPicker() Experimental
- showOpenFilePicker() Experimental
- showSaveFilePicker() Experimental
- sizeToContent() Non-standard
- stop()
- structuredClone()
- webkitConvertPointFromNodeToPage() Non-standard Deprecated
- webkitConvertPointFromPageToNode() Non-standard Deprecated
- Events
- afterprint
- appinstalled
- beforeinstallprompt
- beforeprint
- beforeunload
- blur
- devicemotion
- deviceorientation
- deviceorientationabsolute
- error
- focus
- gamepadconnected
- gamepaddisconnected
- hashchange
- languagechange
- load
- message
- messageerror
- offline
- online
- orientationchange Deprecated
- pagehide
- pagereveal
- pageshow
- pageswap
- popstate
- rejectionhandled
- resize
- scrollsnapchange Experimental
- scrollsnapchanging Experimental
- storage
- unhandledrejection
- unload
- vrdisplayactivate Non-standard Deprecated
- vrdisplayconnect Non-standard Deprecated
- vrdisplaydeactivate Non-standard Deprecated
- vrdisplaydisconnect Non-standard Deprecated
- vrdisplaypresentchange Non-standard Deprecated
- Inheritance
- EventTarget
Từ khóa » Html Javascript Button Alert
-
Tryit Editor V3.7 - JavaScript Alert - W3Schools
-
How To Create Alert Buttons - W3Schools
-
WebD2: Using JavaScript To Show An Alert - University Of Washington
-
How Does JavaScript Onclick Alert Work? - EduCBA
-
JavaScript Alert Messages And Confirmation Messages
-
JavaScript Alert [Examples And Usage] - Alvaro Trigo
-
How To Make A Html Button Clickable And To Show Alert On It
-
JavaScript - Create An Alert On Clicking An HTML Button - Tutorialspoint
-
Button Onlick Show Alert Box - Javascript - Stack Overflow
-
Display Alert Message On Button Click Event Using JavaScript
-
JavaScript Alert() - Javatpoint
-
JavaScript Message Boxes: Alert(), Confirm(), Prompt()
-
Alerts - Bootstrap
-
Javascript Alert Button Code Example