<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>bootbox自定义dialog、confirm、alert样式,基本全局设置方法setDefaults</title>
<link href="http://cdn.bootcss.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet" />
<style>
.btn-myStyle {
background-color: #2c3e50;
color: #fff;
} .btn-myStyle:hover, .btn-myStyle:focus {
color: #fff;
text-decoration: none;
}
</style>
</head>
<body>
<button id="test" class="btn btn-default">测试</button>
<script src="http://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script>
<script src="http://cdn.bootcss.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<script src="http://bootboxjs.com/bootbox.js"></script>
<script>
$(document).ready(function ()
{
//bootbox.setDefaults({
/**
* @optional String
* @default: en
* which locale settings to use to translate the three
* standard button labels: OK, CONFIRM, CANCEL
*/
//locale: "fr",
/**
* @optional Boolean
* @default: true
* whether the dialog should be shown immediately
*/
//show: true,
/**
* @optional Boolean
* @default: true
* whether the dialog should be have a backdrop or not
*/
//backdrop: true,
/**
* @optional Boolean
* @default: true
* show a close button
*/
//closeButton: true,
/**
* @optional Boolean
* @default: true
* animate the dialog in and out (not supported in < IE 10)
*/
//animate: true,
/**
* @optional String
* @default: null
* an additional class to apply to the dialog wrapper
*/
//className: "my-modal"
//});
}); $(document).on("click", "#test", function(e) {
bootbox.confirm("Hello world!", function(result) {
if (result) {
alert('点击了确认按钮');
} else {
alert('点击了取消按钮');
}
});
});
//bootbox.dialog({
// message: "I am a custom confirm",
// title: "Confirm title",
// buttons: {
// Cancel: {
// label: "Cancel",
// className: "btn-default",
// callback: function () {
// alert("Cancel");
// }
// }
// , OK: {
// label: "OK",
// className: "btn-primary",
// callback: function () {
// alert("OK");
// }
// }
// }
//}); /* bootbox.confirm({
buttons: {
confirm: {
label: '我是确认按钮',
className: 'btn-myStyle'
},
cancel: {
label: '我是取消按钮',
className: 'btn-default'
}
},
message: '提示信息',
callback: function(result) {
if(result) {
alert('点击确认按钮了');
} else {
alert('点击取消按钮了');
}
},
//title: "bootbox confirm也可以添加标题哦",
});
*/ //bootbox.alert({
// buttons: {
// ok: {
// label: '我是ok按钮',
// className: 'btn-myStyle'
// }
// },
// message: '提示信息',
// callback: function () {
// alert('关闭了alert');
// },
// title: "bootbox alert也可以添加标题哦",
// });
// }); </script>
</body>
</html>

1.

 $(document).on("click", "#test", function(e) {
bootbox.confirm("Hello world!", function(result) {
if (result) {
alert('点击了确认按钮');
} else {
alert('点击了取消按钮');
}
});
});

2.

 $(document).on("click", "#test", function(e) {
bootbox.dialog({
message: "I am a custom confirm",
title: "Confirm title",
buttons: {
Cancel: {
label: "Cancel",
className: "btn-default",
callback: function () {
alert("Cancel");
}
}
, OK: {
label: "OK",
className: "btn-primary",
callback: function () {
alert("OK");
}
}
}
});
});

效果图:

3.

 $(document).on("click", "#test", function(e) {
bootbox.confirm({
buttons: {
confirm: {
label: '我是确认按钮',
className: 'btn-myStyle'
},
cancel: {
label: '我是取消按钮',
className: 'btn-default'
}
},
message: '提示信息',
callback: function(result) {
if(result) {
alert('点击确认按钮了');
} else {
alert('点击取消按钮了');
}
},
title: "bootbox confirm也可以添加标题哦",
});
});

效果图:

4.

 $(document).on("click", "#test", function (e)
{
bootbox.alert({
buttons: {
ok: {
label: '我是ok按钮',
className: 'btn-myStyle'
}
},
message: '提示信息',
callback: function () {
alert('关闭了alert');
},
title: "bootbox alert也可以添加标题哦",
});
});

效果图:

web前段 弹出小例子的更多相关文章

  1. JS设置弹出小窗口。

    经常上网的朋友可能会到过这样一些网站,一进入首页立刻会弹出一个窗口,或者按一个连接或按钮弹出,通常在这个窗口里会显示一些注意事项.版权信息.警告.欢迎光顾之类的话或者作者想要特别提示的信息.其实制作这 ...

  2. web页面弹出窗口代码大全

    //-----------按钮提示框----------// <input type="button" name="btn2" id="btn2 ...

  3. [js开源组件开发]js手机端浮层控件,并有多种弹出小提示,兼容pc端浏览器

    js dialog组件,包含alert和confirm的实现 本组件所有的资源均在github上可以查看源代码 GitHub 本dialog的组件的例子请在这里查看 demo dialog js di ...

  4. vue.js 利用组件之间通讯,写一个弹出框例子

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  5. layui 在页面弹出小窗口,并关闭

    function showdialog() { layer.open({  type: 2,  title: '发起调度', shadeClose: true, shade: 0.8, area: [ ...

  6. JS 弹出小窗口

    弹出窗口函数 function openwindow(url,name,iWidth,iHeight){ var url; //转向网页的地址; var name; //网页名称,可为空; var i ...

  7. web项目引入extjs小例子

    一个新的项目,前端用extjs实现!分享一下extjs开发的准备工作! 首先去下载extjs的资源包,这里我是随便在网上下载的! 打开之后 ,目录是这样的! 需要关注的几个文件夹: builds:压缩 ...

  8. web页面弹出遮罩层,通过js或css禁止蒙层底部页面跟随滚动

    场景概述 弹窗是一种常见的交互方式,而蒙层是弹窗必不可少的元素,用于隔断页面与弹窗区块,暂时阻断页面的交互.但是,在蒙层元素中滑动的时候,滑到内容的尽头时,再继续滑动,蒙层底部的页面会开始滚动,显然这 ...

  9. Web之-----弹出确认框控件应用

    引用文件!-------- <link rel="stylesheet" type="text/css" href="@Url.FrontUrl ...

随机推荐

  1. CacheManagerUtils.java

    package com.vcredit.framework.utils; import net.sf.ehcache.Cache;import net.sf.ehcache.CacheManager; ...

  2. ASP.NET中如何读取和写入注册表

    直接给源码: 读取注册表内容: RegistryKey regkey=Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Window ...

  3. GROUP BY 與 Null 值

    若群組資料行包含了 Null 值,該資料列將變成結果中的一個群組.若群組資料行內包含了多個 Null 值,Null 值將放入單一群組內.此行為定義於 SQL-2003 標準之中. Product 資料 ...

  4. 【iCore3 双核心板】例程六:IWDG看门狗实验——复位ARM

    实验指导书及代码包下载: http://pan.baidu.com/s/1c0frjHm iCore3 购买链接: https://item.taobao.com/item.htm?id=524229 ...

  5. ThinkPHP 3.2.3 简单后台模块开发(二)RBAC

    RBAC(Role-Based Access Controll)基于角色的访问控制 在 ThinkPHP3.2.3 中 RBAC 类位于 /ThinkPHP/Library/Org/Util/Rbac ...

  6. java json与对象或者集合互转

    package open_exe; public class User { private int id; private String name; private String gender; pu ...

  7. Web Api 中Get 和 Post 请求的多种情况分析

    转自:http://www.cnblogs.com/babycool/p/3922738.html 来看看对于一般前台页面发起的get和post请求,我们在Web API中要如何来处理. 这里我使用J ...

  8. class-dump + DumpFrameworks.pl

    目的:实现生成 private framework 的 .h,以便倒入项目使用私有 api. 一.class-dump 下载地址: http://stevenygard.com/download/ 安 ...

  9. Extjs 图片的自动缩放

    function resizeImage(obj) { var width = Ext.getCmp('welcome').getWidth(); //welcome 为一Panel的id 分割线下的 ...

  10. 关于WPF程序只运行一个实例的方法

    找到的方法有两种: 1)http://www.cnblogs.com/liuyazhou/archive/2009/11/02/1594364.html 2)http://codereview.sta ...