prompt() 方法,彈框帶輸入框,prompt輸入框

來源:互聯網
上載者:User

prompt() 方法,彈框帶輸入框,prompt輸入框

prompt() 



有alert的風格,卻帶著輸入框,這是怎麼實現的呢?


文法
prompt(text,defaultText)
參數 描述
text 可選。要在對話方塊中顯示的純文字(而不是 HTML 格式的文本)。
defaultText 可選。預設的輸入文本。
說明

如果使用者單擊提示框的取消按鈕,則返回 null。如果使用者單擊確認按鈕,則返回輸入欄位當前顯示的文本。

在使用者點擊確定按鈕或取消按鈕把對話方塊關閉之前,它將阻止使用者對瀏覽器的所有輸入。在調用 prompt() 時,將暫停對 JavaScript 代碼的執行,在使用者作出響應之前,不會執行下一條語句。

執行個體 1
<html><head><script type="text/javascript">function disp_prompt()  {  var name=prompt("Please enter your name","")  if (name!=null && name!="")    {    document.write("Hello " + name + "!")    }  }</script></head><body><input type="button" onclick="disp_prompt()"value="Display a prompt box" /></body></html>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.