web前段 弹出小例子
<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前段 弹出小例子的更多相关文章
- JS设置弹出小窗口。
经常上网的朋友可能会到过这样一些网站,一进入首页立刻会弹出一个窗口,或者按一个连接或按钮弹出,通常在这个窗口里会显示一些注意事项.版权信息.警告.欢迎光顾之类的话或者作者想要特别提示的信息.其实制作这 ...
- web页面弹出窗口代码大全
//-----------按钮提示框----------// <input type="button" name="btn2" id="btn2 ...
- [js开源组件开发]js手机端浮层控件,并有多种弹出小提示,兼容pc端浏览器
js dialog组件,包含alert和confirm的实现 本组件所有的资源均在github上可以查看源代码 GitHub 本dialog的组件的例子请在这里查看 demo dialog js di ...
- vue.js 利用组件之间通讯,写一个弹出框例子
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- layui 在页面弹出小窗口,并关闭
function showdialog() { layer.open({ type: 2, title: '发起调度', shadeClose: true, shade: 0.8, area: [ ...
- JS 弹出小窗口
弹出窗口函数 function openwindow(url,name,iWidth,iHeight){ var url; //转向网页的地址; var name; //网页名称,可为空; var i ...
- web项目引入extjs小例子
一个新的项目,前端用extjs实现!分享一下extjs开发的准备工作! 首先去下载extjs的资源包,这里我是随便在网上下载的! 打开之后 ,目录是这样的! 需要关注的几个文件夹: builds:压缩 ...
- web页面弹出遮罩层,通过js或css禁止蒙层底部页面跟随滚动
场景概述 弹窗是一种常见的交互方式,而蒙层是弹窗必不可少的元素,用于隔断页面与弹窗区块,暂时阻断页面的交互.但是,在蒙层元素中滑动的时候,滑到内容的尽头时,再继续滑动,蒙层底部的页面会开始滚动,显然这 ...
- Web之-----弹出确认框控件应用
引用文件!-------- <link rel="stylesheet" type="text/css" href="@Url.FrontUrl ...
随机推荐
- MySQL启动错误排查
一般情况下mysql的启动错误还是很容易排查的,但是今天我们就来说一下不一般的情况.拿到一台服务器,安装完mysql后进行启动,启动错误如下: 有同学会说,哥们儿你是不是buffer pool设置太大 ...
- OpenGL 小游戏 贪吃蛇1(2D)
#include "stdafx.h" #include <GL/glut.h> #include <stdlib.h> #pragma comment(l ...
- javascript 百度地图
官方地址 http://lbsyun.baidu.com/index.php?title=jspopular 示例地址 http://developer.baidu.com/map/jsdemo.ht ...
- HDU1004之总是wa的细节问题
#include <stdio.h> #include <string.h> int main() { ][]; int n, i, k, j, max, max_i; ){ ...
- Android课程---计算器的实现
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="ht ...
- HDU 4358 Boring counting(莫队+DFS序+离散化)
Boring counting Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 98304/98304 K (Java/Others) ...
- Asp.net DropDownList 自定义样式(想怎么改就怎么改!)
最近在做一个asp.net的项目,需要对默认的dropdownlist样式进行美化,固有的dropdownlist的小箭头实在让人无法接受,于是开始在百度,google 上下求索,天不负有心人,终于找 ...
- 图文详解MFC程序设置菜单快捷键
原来觉得添加个快捷键就只要几分钟,上网搜索文章都写得很模糊, 只有这边文章不错. http://www.cplusplus.me/1263.html http://blog.sina.com.cn/s ...
- ThinkPHP的缓存技术
原文:ThinkPHP的缓存技术 如果没有缓存的网站是百万级或者千万级的访问量,会给数据库或者服务器造成很大的压力,通过缓存,大幅减少服务器和数据库的负荷.假如我们 把读取数据的过程分为三个层,第一个 ...
- 【C++】类型转换(学习笔记)
1. 隐式类型转换,相关联的类型(e.g.int vs double)之间可以发生隐式类型转换. 比如,在条件中,非布尔类型转为布尔类型: 初始化时,初始值变为变量类型: 赋值时,右值变成左侧的类型: ...