Sunday, February 26, 2017

javascript alert like div example

By using bootbox js library we can create a dialogue box like javascript alert. i have tried different types and then commented it. you can just uncomment it to see its effect. For more description and uses visit its page Bootbox Page Link

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Basic Bootstrap Template</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/bootbox.js/4.4.0/bootbox.min.js" ></script>
    <script type="text/javascript">
    $('document').ready(function(){
    $('#alert').click(function(){
    //bootbox.alert("Your message here…");
    /*bootbox.alert("This is an alert with a callback!", function(){
    console.log('This was logged in the callback!');
    });*/
bootbox.alert({
   message: "This is an alert with a callback!",
   size: 'large', // small,large
   backdrop: true,
   callback: function () {
       console.log('This was logged in the callback!');
   }
});
/*bootbox.confirm("This is the default confirm!", function(result){
console.log('This was logged in the callback: ' + result);
});*/
/*bootbox.confirm({
   message: "This is an alert with a callback!",
   size: 'large', // small,large
   backdrop: true,
   callback: function (result) {
       console.log('This was logged in the callback! '+result);
   }
});*/
/*bootbox.confirm({
   message: "This is a confirm with custom button text and color! Do you like it?",
   buttons: {
       confirm: {
           label: 'Yes',
           className: 'btn-success'
       },
       cancel: {
           label: 'No',
           className: 'btn-danger'
       }
   },
   callback: function (result) {
       console.log('This was logged in the callback: ' + result);
   }
});*/
/*var dialog = bootbox.confirm({
   title: "Destroy planet?",
   message: "Do you want to activate the Deathstar now? This cannot be undone.",
   buttons: {
       cancel: {
           label: '<i class="fa fa-times"></i> Cancel'
       },
       confirm: {
           label: '<i class="fa fa-check"></i> Confirm'
       }
   },
   callback: function (result) {
       console.log('This was logged in the callback: ' + result);
   }
});
dialog.init(function(){
   setTimeout(function(){
       dialog.find('.bootbox-body').html('I was loaded after the dialog was shown!');
   }, 3000);
});*/

    });    
    });
   
    </script>
</head>
<body>
<button id="alert">For Alert</button>
<!-- <div class="alert alert-info fade in">
   <a href="#" class="close" data-dismiss="alert">&times;</a>
   <strong>Note!</strong> Please read the <a href="#" class="alert-link">comments</a> carefully.
</div>
<div class="alert alert-warning fade in">
   <a href="#" class="close" data-dismiss="alert">&times;</a>
   <strong>Warning!</strong> There was a problem with your network connection.
</div> -->
</body>
</html>