javascript pop up boxes

Javascript allows us to choose from 3 different types of pop up boxes which are as follows.


alert() command is used to display some general information to the users in a pop up box whenever some event is initialized. ok button is needed to be clicked by the users to proceed further. This command is highly useful whenever you want to make sure the users noticed some information.

  alert("Your Information Here!!!");


confirm() command appears with 2 options ok and cancel. If the user clicks on ok the next block of commands will be executed while the execution of command lines further down the line will be cancelled if the user clicks cancel. This command is very useful when you want the user to verify some sort of action request is made by the user knowingly like request to delete some data or request to leave the page. Here's an example

<button onclick="return confirmIt()">Delete</button>
function confirmIt(){
  var x = confirm("are you sure?");
  if(x == true){
    alert('Data deleted successfully.');
    alert('Data not deleted.');


prompt() command is used to ask for some input rom the user where the user must enter something to proceed further. A default value is placed inside the input box which will be used in case the user opted to proceed without entering any data in the input field. This command also comes with 2 buttons ok and cancel. If the user clicks on the cancel button, the prompt button will return null value and exits the function. Here's an example.

<button onclick="return yourName()">Click me</button>
function yourName(){
  var x = prompt("Please enter your name.","webtrickshome");

0 Like 0 Dislike 0 Comment Share

Leave a comment