SQL PHP HTML ASP JavaScript articles and free scripts to download
JavaScript Tutorials
Popular Tutorials
Drop down list
Timer function
JavaScript Tutorials
String
Array
Date & Time
Form Validation
Event Handling
Math Functions
JavaScript Forum
Subscribe
Submit your email address and receive article and product notifications. Your email is safe with us.

 
 

Displaying Alert window with message

We can display alert messages in a new window to the visitor using client side JavaScript alert function. This is one useful tool to inform or alert the user by displaying some messages. Alert message window will have only one button displaying “OK” and there is no conform or cancel button. To get the user input by displaying conform or cancel buttons we have to use confirm window function. Alerts can be programmed to display different messages based on requirements and it can be programmed by using server side scripting languages. But for showing alert window we have to use JavaScript commands only.

In our example we have shown one button and called a function show_alert by connecting it to onClick event of the button.

Here is the code to display an alert message window.

var msg = "Welcome to plus2net.com";
alert(msg);

Here msg is the variable and we are displaying the text stored inside the variable msg in the alert box.
Here is the demo of this code. Click the button below to display the alert message.



Here is the code of the alert window.

<html><head>
<title>(Type a title for your page here)</title>
<script type="text/javascript">
function show_alert() {
var msg = "Welcome to plus2net.com";
alert(msg);
}
</script>
</head>

<body >

<input type=button value='Click here to display alert message' OnClick="show_alert()">

</body></html>
Further readings
Displaying alert window with message
prompt window for user input
Confirm window for user choice
Opening a child window
Closing child window on click of a button
Refreshing parent window from child window
Passing of data from child window to parent window
Showing a conformation window to user before deleting
Displaying JavaScript pop up window
 
Subscribe
Submit your email address and receive article and product notifications. Your email is safe with us.

Scripts
PHP
JavaScript