Search the Blog

Monday, August 5, 2019

Javascript window.alert() concept code and syntax with demo example

The Window alert method displays a visual alert box on screen.
This method parameter is displayed to the user in plain text:

Syntax 1- window.alert(message)

Syntax 2- alert(message)

Note:- Window is global object.

Code:-window.alert("Do you want real to send request?");

Output:-

Note:- Alert method is technically a property of window. so that's why it becomes a global object and we can use this any window.


 Alert always acts as a modal prompt that means the code calling alert
 will pause/hold until the prompt is not answered . that means no other JavaScript
code will execute until the alert is dismissed:

JavaScript Code to hold the Display-
  alert('Pause!');
 console.log('Alert was dismissed');


1 comment:

Translate