Skill Making

Always Increase Your Knowledge

Use of Confirm Box in JavaScript| Use of JavaScript with HTML file

Use of Confirm Box in JavaScript| Use of JavaScript with HTML file

 

In this article, I will share some information about the use of confirm box in JavaScript. If you also want to know the use of confirm box then you must read this article till the end.

In the previous article, you learned about the Use of Alert Box in JavaScript.

What is Confirm Box in JavaScript?

How to use confirm box in JavaScript?

If you have both these questions then you should read this article till the end. Here I will explain to you about this topic with an example.




If you want to boost your JavaScript Knowledge then you should buy this book. I recommend it for every JavaScript learner. You must read this.

Confirm Box

  1. Confirm box has two buttons where first one is “OK” and second one is “cancel”.
  2. Here the browser needs some confirmation from the user.
  3. When a confirm box popup, the user will have to click either “OK” or “Cancel” to proceed.
  4. If the user clicks “OK”, the box returns true. If the user clicks “Cancel”, the box returns false.

Code:

confirm(“Some Message”);

Example:

<!DOCTYPE html>

<html>

<head>

	<title>Pop Up Boxes</title>

<script type="text/javascript">

	var x=confirm("This is confirm box");

	if(x){

		document.getElementsByTagName("body")[0].style.backgroundColor="blue";

	}

</script>
</head>
<body>
<h1>Welcome</h1>
</body>






</html>

The output of Use of Confirm Box in JavaScript

Picture of Confirm Box in JavaScript

Conclusion

Finally, you got information about the use of confirm box in JavaScript. I hope you got some informative article. If you like it as useful then please share it with your friends. Thank you for reading this article till the end.




You should also read these articles.

Alert Box in JavaScript

Control Statements in JavaScript

1 Comment

Add a Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Skill Making © 2018 Frontier Theme