Alert: Modal Message BoxQuestion: How do I display an alert message from JavaScript?
Answer: To display an alert message (a simple modal message box), use the window.alert('Message goes here') The button above was created using the following code: <form name=myform> <input type=button value="Try it now" onClick="alert('Hello from JavaScript!')"> </form>Note that alert() is a method of the window object.
Thus, all of the following JavaScript statements produce similar results:
alert('message') window.alert('message') // reference to current window self.alert('message') // reference to current window top.alert('message') // top-level frameset parent.alert('message') // parent frame in a frameset
Returned value. The See also other JavaScript dialogs: |
Copyright © 1999-2011, JavaScripter.net.