Alert訊息框的使用

2021-08-30 01:55:43 字數 1022 閱讀 8093

1、修改預設的按鈕標籤

alert.yeslabel = "是";

alert.nolabel = "否";

alert.oklabel = "確定";

alert.cancellabel = "取消";

2、為按鈕指定自定義事件

alert.show("確定要提交嗎?", "提示", alert.ok|alert.cancel, null, alertclose);

private function alertclose(event: closeevent):void

}  3、設定icon圖示

[bindable]

[embed(source='question.png')]

private var icon: class;

alert.show("確定要提交嗎?", "提示", alert.ok|alert.cancel, null, alertclose, icon);

4、設定alert的疊加層的顏色

var alertcss: cssstyledeclaration = stylemanager.getstyledeclaration("alert");

alertcss.setstyle("modaltransparencycolor", "haloorange");

alertcss.setstyle("themecolor", "haloorange");

var alert:alert = alert.show("確定要提交嗎?", "提示", alert.ok|alert.cancel, null, alertclose, icon);

5、通過樣式自定義alert的風格

alert  

--標題的樣式

.mycustomtitlestylename

--訊息的樣式

.mycustommessagestylename

--按鈕的樣式

.mycustombuttonstylename

替代alert的訊息框和提示框

alert提示框由於外觀不太友好,所以一般都不用alert了。我在這裡使用bootstrap的樣式,寫了乙個可以單獨顯示訊息,也可以確認取消的提示框,確認,取消的採用模式對話方塊方式,用乙個div遮蓋了後面所有內容。使用的外觀如下 一 單獨顯示訊息 二 確認和取消 單獨顯示訊息的方法傳遞型別,資訊,...

自動消失的alert框

m實現檔案 uialertview basealert 宣告的全域性變數 此處一定要注意 ibaction pressme id sender void performdismiss nstimer timer h宣告檔案 標頭檔案 import inte ce viewcontroller uiv...

使用訊息框

可以使用警告 確認和提示訊息框來獲得使用者的輸入。這些訊息框是 window物件的介面方法。由於 window 物件位於物件層次的頂層,因此實際應用中不必使用這些訊息框的全名 例如 window.alert 不過採用全名是乙個好注意,這樣有助於您記住這些訊息框屬於哪個物件。alert方法有乙個引數,...