Home > Web Front-end > JS Tutorial > Use window.prompt() to pop up a dialog box for user input_javascript skills

Use window.prompt() to pop up a dialog box for user input_javascript skills

WBOY
Release: 2016-05-16 16:04:30
Original
9999 people have browsed it

I accidentally saw the window.prompt() method. I have never used it before and I am very ignorant. But let’s study now.

In a web page, sometimes a prompt box needs to pop up, and the user also needs to input some content in the prompt box. In this case, the prompt object can be used. The specific implementation is as follows.

<!DOCTYPE html>
 <html>
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
 <script>
   var _saytext = decodeURI("我真笨");
   
   var _text;
   
   var err_list = new Array("别乱填!!","快填,别试了!!");
   
   _text = prompt("在下面输入框填“" + _saytext +"”");
   
   for ( i = 0; _text != _saytext; ++i) {
     if ( i == err_list.length) {
      i = 0;
     }
     alert(err_list[i]);
     _text = prompt("在下面输入框填“" + _saytext +"”");
   }
   
   alert("嗯,这就对了!");
 </script>
 </head>
 </html>
Copy after login

The above is the entire content of this article, I hope you all like it.

Related labels:
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