How to Create a JavaScript Alerts?
Demo- Create JavaScript Alerts.
JavaScript Alert Boxes | ||
JavaScript alert box show a message to the user. You can display the message with multiple lines using '\n' | ||
» | How to create Simple JavaScript Alert Box | |
» | How to break lines in a javascript alert message | |
» | Display custom message in javascript alert | |
Enter your Message | ||
» | Display screen size using an alert | |
» | Display the URL of current web page | |
JavaScript Prompt Messages | ||
JavaScript prompt dialog box provide a text box to the user to enter text input. Also you can define a default value. It returns user's input if the user has entered a value. Otherwise it returns the default value. But it returns 'null' if there is no any value present in the text box. | ||
» | Prompt user name | |
» | Adding two numbers using prompt messages | |
JavaScript Confirm Messages | ||
JavaScript confirm dialog box returns true or false according to user response. If user clicks on 'Yes' button it returns 'true' and if user clicks on 'Cancel' button or close the message window it returns 'false' | ||
» | Simple confirm message | |
» | Use confirm dialog to go to another web page |
Try It!
1. Example code for create a alert box in javascript.
JavaScript Code
<script type="text/javascript" language="javascript">
<!--
function simpleAlert(){
window.alert("This is a simple javascript alert");
return false;
}
-->
</script>
HTML Code
<html>
<head><title>How to create a simple alert </title>
</head><body>
<table border="0"><tr>
<td> <input name="btnmessage" type="submit" id="btnmessage" onclick="javascript:simpleAlert();" value="Click Here " /></td>
<td> </td></tr>
</table>
</body>
</html>
2. Example code for create a multi line alert in JavaScript.
JavaScript Code
<script type="text/javascript" language="javascript">
<!--
function lineBreakAlert(){
window.alert("You can display multiple lines in your message\n1.This is the second line\n2.This is third line\nUse \'\\n\' to break lines in your message");
return false;
}
-->
</script>
HTML Code
<html>
<head><title>How to create a multiple line alert </title>
</head><body>
<table border="0"><tr>
<td> <input name="btnmessage" type="submit" id="btnmessage" onclick="javascript:lineBreakAlert();" value="Click Here " /></td>
<td> </td></tr>
</table>
</body>
</html>
3. Example code for create a prompt dialog box in JavaScript.
JavaScript Code
<script type="text/javascript" language="javascript">
<!--
function promptName(){
var name=window.prompt("Please enter your Name","");
if(name==null){
alert("Please enter your name");
return false;
}else{
if(name!=""){
alert("Your Name is "+name);
return false;
}else{
alert("Please enter your name");
return false;
}
}
}
-->
</script>
HTML Code
<html>
<head><title>How to create a multiple line alert </title>
</head><body>
<table border="0"><tr>
<td> <input name="btnmessage" type="submit" id="btnmessage" onclick="javascript:promptName();" value="Click Here " /></td>
<td> </td></tr>
</table>
</body>
</html>
4. Example code for create a confirm dialog box in JavaScript.
JavaScript Code
<script type="text/javascript" language="javascript">
<!--
function simpleConfirm(){
var response=confirm("Click \'Ok\' or \'Cancel\'");
alert("You clicked "+(response==true?"Ok":"Cancel")+" button");
}
-->
</script>
HTML Code
<html>
<head><title>How to create a confirm dialog box </title>
</head><body>
<table border="0"><tr>
<td> <input name="btnmessage" type="submit" id="btnmessage" onclick="javascript:simpleConfirm();" value="Click Here " /></td>
<td> </td></tr>
</table>
</body>
</html>
JavaScript Validation
6 comments:
Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a Front end developer learn from javascript and jquery training in chennai . or learn thru Javascript Training in Chennai. Nowadays JavaScript has tons of job opportunities on various vertical industry. javascript and jquery training in chennai
Great Article
IEEE Final Year Projects for CSE
IEEE Project Centers in Chennai
1
2
3
4
5
6 osg777 download
7
8
Excellent post...! It is a very great idea and unique content. Thank you so much...
Excel Training in Chennai
Excel Advanced course
Unix Training in Chennai
Linux Training in Chennai
Graphic Design Courses in Chennai
Tableau Training in Chennai
Pega Training in Chennai
Primavera Training in Chennai
Oracle Training in Chennai
Oracle DBA Training in Chennai
Power BI Training in Chennai
Appium Training in Chennai
Very nice informative blog. Actually it's great article. Thanks for sharing unique content. oracle training in chennai
Your post is really good. It is really helpful for me to improve my knowledge in the right way..
benefits of seo
correct pronunciation of english words
web design articles
selenium testing tool
salesforce integration interview questions
salesforce interview questions for experienced
Post a Comment