Using JavaScript how do we show an alert to the user?

 Posted by Vivek.Ramapuram on 8/11/2014 | Category: JavaScript Interview questions | Views: 413 | Points: 40
Answer:

In this case, we should use alert method... to alert user with some information in JavaScript. It is an important method for every Java script to show an alert information on the page.


Example Script:
<script type="text/javascript">

function confirmMe() {
var v = confirm("Are you sure to confirm?");
if (v) {
//ok pressed; user confirmed to proceed further
//write code to execute code
alert("Go ahead");
}
else {
//cancel pressed; user don't want to proceed
alert("Stop")
}
}

</script>


Html
<input type="button" onclick="confirmMe()" />


Asked In: While Learning | Alert Moderator 

Comments or Responses

Login to post response