古詩詞大全網 - 個性簽名 - 如何在網頁中顯示對話框

如何在網頁中顯示對話框

可以使用javascript腳本語言,例子如下:

1.打開文本編輯器或記事本程序,輸入

& lthtml & gt

& lthead & gt& lt/head & gt;

& ltbody & gt& lt/body & gt;

& lt/html & gt;

2.在…裏

& ltscript type = " text/JavaScript " & gt;

& lt/script & gt;

3.在…裏

函數對花()

{

Alert("這個窗口是壹個對話框!")

}

4.然後,定義壹個名為queren()的函數來彈出壹個確認框:

函數queren()

{

Var se=confirm("請點擊壹個按鈕!");

if (se==true)

{

Alert("妳按了OK ");

}

其他

{

Alert("妳按了取消");

}

}

5.繼續定義另壹個函數tishi(),用於在網頁中彈出提示框。

函數tishi()

{

Var t=prompt("請輸入您的姓名","國王視覺")

如果(t!= null & amp& ampt!="")

{

Document.write("精彩的MV在這裏,"+t+"!妳的世界》)

}

}

6、函數定義後,在

& ltinput type = " button " onclick = " duihua()" value = "單擊顯示對話框"/& gt;

& ltinput type = " button " onclick = " queren()" value = "單擊以顯示確認框"/& gt;

& ltinput type = " button " onclick = " tishi()" value = "單擊顯示提示框"/& gt;

7.保存文件,用ie瀏覽器打開,點擊相應的按鈕,彈出相應的對話框。