Home > Web Front-end > JS Tutorial > Examples of usage of js confirm() method_javascript skills

Examples of usage of js confirm() method_javascript skills

WBOY
Release: 2016-05-16 17:28:57
Original
1404 people have browsed it

Confirm() returns true if the user clicks the OK button. If the cancel button is clicked, confirm() returns false.

It will block all user input to the browser until the user clicks the OK button or the Cancel button to close the dialog box. When confirm() is called, execution of the JavaScript code is paused and the next statement is not executed until the user responds.

Let’s learn how to use it through these two small examples:

Copy the code The code is as follows:



How to use confrim









js confirm
<script><br>function begin()<br>{<br> var a =confirm("Are Guo Yang and Xiaodai good friends?");<br> if(a==true)<br> {<br> /*document.write("Congratulations on the correct answer!");* /<br> alert("Congratulations on getting the answer right!");<br> begin();<br> }<br> else<br> {<br> /*document.write("You are such a pig, it’s so simple You can’t answer all the questions! ");*/<br> alert("You are such a pig, you can’t answer such a simple question!");<br> begin();<br> }<br> }<br> </script>




Related labels:
js
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template