After the parentheses you need a pair of curly brackets. Now it takes two parameters. If the user clicks "Cancel", the box returns false. The basic structure of a homemade function A function definition starts with the word function.
An Example of a Simple Function Figure shows you how the window-centering code in Figure looks rewritten as a web page containing a function. If the user clicks "Cancel" the box returns null.
This is required if you want to return a value from a function. Next Page A function is a group of reusable code which can be called anywhere in your program. If the user clicks "OK" the box returns the input value. It defines a function that takes two parameters and concatenates them before returning the resultant in the calling program.
How TO - Alerts Alerts. Alert messages can be used to notify the user about something special: danger, success, information or warning. The alert() method displays an alert box with a specified message and an OK button. An alert box is often used if you want to make sure information comes through to the user.
Note: The alert box takes the focus away from the current window, and forces the browser to read the message.
Tour Start here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site.Download