可以用jDialog插件實(shí)現(xiàn),jDialog是一款基于jquery實(shí)現(xiàn)的輕量級(jí)多種類型的自定義對(duì)話框插件在項(xiàng)目開(kāi)發(fā)中、一般會(huì)美化 alert();

成都創(chuàng)新互聯(lián)公司主要從事網(wǎng)站建設(shè)、做網(wǎng)站、網(wǎng)頁(yè)設(shè)計(jì)、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)云安,十年網(wǎng)站建設(shè)經(jīng)驗(yàn),價(jià)格優(yōu)惠、服務(wù)專業(yè),歡迎來(lái)電咨詢建站服務(wù):13518219792
參考如下:
center
button id="test1"alert方式調(diào)用/button
br/br/
button id="test2"confirm方式調(diào)用/button
br/br/
button id="test3"iframe方式調(diào)用/button
br/br/
button id="test4"只顯示內(nèi)容對(duì)話框/button
br/br/
button id="test5"對(duì)話框配置按鈕/button
br/br/
button id="test6"message方式調(diào)用/button
br/br/
button id="test7"tip方式調(diào)用/button
/center
以下是JS代碼
$("#test1").click(function(){
var dialog = jDialog.alert(′歡迎使用jDialog組件′,{},{
showShadow: false,// 不顯示對(duì)話框陰影
buttonAlign : ′center′,
events : {
show : function(evt){
var dlg = evt.data.dialog;
},
close : function(evt){
var dlg = evt.data.dialog;
},
enterKey : function(evt){
alert(′enter key pressed!′);
},
escKey : function(evt){
alert(′esc key pressed!′);
evt.data.dialog.close();
}
}
});
}) ;
$("#test2").click(function(){
var dialog = jDialog.confirm(′歡迎使用jDialog組件,我是confirm!′,{
handler : function(button,dialog) {
alert(′你點(diǎn)擊了確定!′);
dialog.close();
}
},{
handler : function(button,dialog) {
alert(′你點(diǎn)擊了取消!′);
dialog.close();
}
});
});
$("#test3").click(function(){
// 通過(guò)options參數(shù),控制iframe對(duì)話框
var dialog = jDialog.iframe(;,{
title : ′
width : 1100,
height : 550
});
});
$("#test4").click(function(){
// 通過(guò)options參數(shù),控制dialog
var dialog = jDialog.dialog({
title : ′自定義對(duì)話框′,
content : ′
});
});
$("#test5").click(function(){
// 通過(guò)options參數(shù),控制dialog
var dialog = jDialog.dialog({
title : ′自定義對(duì)話框′,
content : ′;,
buttons : [
{
type : ′highlight′,
text : ′你好′,
handler:function(button,dialog)
{
dialog.close();
}
}
]
});
});
$("#test6").click(function(){
var dialog = jDialog.message(′′,{
autoClose : 3000, // 3s后自動(dòng)關(guān)閉
padding : ′30px′, // 設(shè)置內(nèi)部padding
modal: true // 非模態(tài),即不顯示遮罩層
});
});
$("#test7").click(function(){
var dialog = jDialog.tip(′′,{
target : $(′#test7′),
position : ′left-top′,
trianglePosFromStart :0,
autoClose : 1000,
offset : {
top :-20,
left:10,
right:0,
bottom:0
}
});
})
confirm()方法就是對(duì)話框
$(function(){
$('div').click(function(){
if(confirm("你要彈出對(duì)話框嘛!")){
document.write("彈出對(duì)話框");
}
})
})
1、實(shí)現(xiàn)對(duì)話框,首先新建一個(gè)jsp頁(yè)面,去掉設(shè)置路徑,保證js和css樣式的路徑的正確性
2、引入對(duì)話框所需要的js文件和css樣式文件
3、
利用制作兩個(gè)按鈕
打開(kāi)
關(guān)閉
4、
在中添加一個(gè)table
姓名:
性別:
年齡:
電話:
地址:
5、啟動(dòng)服務(wù)器,在...
jquery插件有兩種,一種是$('.xxx').xxx(); 另一種是$.xxx();
自定義jquery插件,我理解是插件的寫法啦。如下面示例代碼
// crud 是插件的名字,可以替換成別的
// 1
(function($, window, document, undefined){
$.fn.crud = function(options){
var opts = $.extend({}, $.fn.crud.defaults, options);
this.each(function(){
// 這里是這個(gè)插件實(shí)現(xiàn)方法主內(nèi)容
});
};
$.fn.crud.defaults = {
// 插件的參數(shù)
};
}(jQuery, window, document));
// 調(diào)用方法 $('.xxx').crud({});
// 2
(function($, window, document, undefined){
$.fn.extend.crud = function(options){
var opts = $.extend({}, $.fn.extend.crud.defaults, options);
this.each(function(){
// 這里是這個(gè)插件實(shí)現(xiàn)方法主內(nèi)容
});
};
$.fn.extend.crud.defaults = {
// 插件的參數(shù)
};
}(jQuery, window, document));
// 調(diào)用方法 $.crud({});
有很多方法實(shí)現(xiàn)的,比如使用alert這種比較丑的彈框,比如
btn.click(function(){
window.alert('內(nèi)容')
});
或者是自己自定義的彈框,那這樣的話你至少得套三個(gè)div,比如
div-----這個(gè)絕對(duì)定位到整個(gè)頁(yè)面,如position:absolute;top:0;left:0;right:0;bottom:0;
div-----這個(gè)在父級(jí)元素上面做絕對(duì)定位,也就是彈框的位置
div/div----彈框內(nèi)容
/div
/div
或者是jQuery UI本身所附帶的對(duì)話框功能,那個(gè)百度就出來(lái)了,不過(guò)不建議用那個(gè),感覺(jué)比較丑,還是自己寫一個(gè)好看
當(dāng)然你也可以試著引入其他的UI框架,比如boot都有對(duì)話框的功能,不過(guò)建議自己寫,用jQuery寫也比較簡(jiǎn)單
網(wǎng)頁(yè)標(biāo)題:對(duì)話框jquery,對(duì)話框刪除了怎么恢復(fù)聊天記錄
分享網(wǎng)址:http://chinadenli.net/article31/dsgjgpd.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供云服務(wù)器、響應(yīng)式網(wǎng)站、網(wǎng)站營(yíng)銷、品牌網(wǎng)站制作、服務(wù)器托管、外貿(mào)網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)