Use window.prompt of to pop up a dialog box for user input
- 2020-05-27 04:15:41
- OfStack
I came across the window.prompt() method, which has never been used before. But let's do it now.
In the web page, sometimes need to pop up a prompt box, and in the prompt box also need the user to enter 1 some content, this can use prompt object, the specific implementation of the usage is as follows.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script>
var _saytext = decodeURI(" How stupid of me ");
var _text;
var err_list = new Array(" Don't fill it out!! "," Fill it out, don't try!! ");
_text = prompt(" Enter" " + _saytext +" " ");
for ( i = 0; _text != _saytext; ++i) {
if ( i == err_list.length) {
i = 0;
}
alert(err_list[i]);
_text = prompt(" Enter" " + _saytext +" " ");
}
alert(" Well, that's right! ");
</script>
</head>
</html>
That's all for this article, I hope you enjoy it.