使用window.prompt()實現(xiàn)彈出用戶輸入的對話框
來源:易賢網(wǎng) 閱讀:1657 次 日期:2015-04-20 14:34:52
溫馨提示:易賢網(wǎng)小編為您整理了“使用window.prompt()實現(xiàn)彈出用戶輸入的對話框”,方便廣大網(wǎng)友查閱!

無意中看到window.prompt()方法,之前真沒有使用過,孤陋寡聞。不過現(xiàn)在學習下吧。

在網(wǎng)頁中,有時需要彈出一個提示框,而且在提示框中還需要用戶輸入一些內(nèi)容,這就可以用prompt對象,具體實現(xiàn)用法如下。

<!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>

更多信息請查看IT技術(shù)專欄

更多信息請查看腳本欄目
易賢網(wǎng)手機網(wǎng)站地址:使用window.prompt()實現(xiàn)彈出用戶輸入的對話框
關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機站點

版權(quán)所有:易賢網(wǎng)