"Simple messaging alerts"
Bootstrap 3.3.0 Snippet by vikrant2mahajan

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<!------ Include the above in your HEAD tag ---------->
<div class="container">
<div class="row">
<h2>Simple Bootstrap alerts for every day use</h2>
<h4>All messages close automatically after 6 seconds·<small>(Can be changed in js)</small></h4>
<button class="btn btn-info" onclick="info('Your info is saved properly.')">Info</button>
<button class="btn btn-warning" onclick="warning('Are you sure ?')">Warning</button>
<button class="btn btn-danger" onclick="error('Unknown error occurred.')">Error</button>
<button class="btn btn-success" onclick="success('All Saved.')">Success</button>
</div>
</div>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
.top-alert {
position: fixed;
top: 0px;
width: 100%;
z-index: 100000;
left: 0;
padding: 20px;
display: inline-block;
text-align: center;
}
.top-alert .alert {
width: auto !important;
height: 100%;
display: inline;
position: relative;
margin: 0;
}
.top-alert .alert .close {
position: absolute;
top: 11px;
right: 10px;
color: inherit;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
window.error = function(msg) {
var dom = '<div class="top-alert"><div class="alert alert-danger alert-dismissible fade in " role="alert"><i class="glyphicon glyphicon-exclamation-sign"></i>·' + msg + '<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button></div></div>';
var jdom = $(dom);
jdom.hide();
$("body").append(jdom);
jdom.fadeIn();
setTimeout(function() {
jdom.fadeOut(function() {
jdom.remove();
});
}, 6000);
}
window.warning = function(msg) {
var dom = '<div class="top-alert"><div class="alert alert-warning alert-dismissible fade in " role="alert"><i class="glyphicon glyphicon-question-sign"></i>·' + msg + '<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button></div></div>';
var jdom = $(dom);
jdom.hide();
$("body").append(jdom);
jdom.fadeIn();
setTimeout(function() {
jdom.fadeOut(function() {
jdom.remove();
});
}, 6000);
}
window.info = function(msg) {
var dom = '<div class="top-alert"><div class="alert alert-info alert-dismissible fade in " role="alert"><i class="glyphicon glyphicon-info-sign"></i>·' + msg + '<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button></div></div>';
var jdom = $(dom);
jdom.hide();
$("body").append(jdom);
jdom.fadeIn();
setTimeout(function() {
jdom.fadeOut(function() {
jdom.remove();
});
}, 6000);
}
window.success = function(msg) {
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Related: See More


Questions / Comments: