SQL PHP HTML ASP JavaScript articles and free scripts to download
JavaScript Window Object

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.

demo of window alert

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>

Here we have displayed a variable data in our alert window. Same way we can display input data of the user from a text box or from any other input field in a alert window. This is used by developers to check the status of the variables at different stage of script execution.

Try to develop a script which will take the user input from a text box and display them in an alert window.

Solution ?

Check this demo on Alert with message box


Google+

placidius03-05-2012
this code has been useful to me, thank you very much for your sharing.
Post Comment This is for short comments only. Use the forum for more discussions.
Name
Email( not to be displayed)Privacy Policy
1+2=This is to prevent automatic submission by spammers. Please enter the result of the sum as asked

Window Object
• Displaying alert window



Join Our Email List
Email:  
For Email Newsletters you can trust
HTML . MySQL. PHP. JavaScript. ASP. Photoshop. Articles. FORUM Contact us

©2000-2014 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer