Andrew Pallant

Software & Web Developer

Donate To Support My Blog Donate if this post helped you. Coffee money is always welcomed!

Simple JS Dialog

Physical Link: Simple JS Dialog

Keeping in the spirit of using my blog as a quick code repository; sometimes you just need a simple easy to implement dialog box. I have been using the following routine for sometime now. Sometimes you just need a simple piece of code to get the project done. This although is very simple, it does the job perfectly. It is not how I often style it, but you can figure that out.

See Working Copy: view & try

Download Sample: download

See Code Below:

 <!DOCTYPE html>  
 <html xmlns="http://www.w3.org/1999/xhtml">  
   <button id="btn-sample">View Sample</button>  
   <div id="msgBox"></div>  
   <script src="Scripts/jquery-1.10.2.js"></script>  
   <script src="Scripts/jquery-ui.js"></script>  
   <link href="Scripts/jquery-ui.css" rel="stylesheet" />  
   <script type="text/javascript">  
     $(document).ready(function () {  
       $("#btn-sample").click(function () {  
         messagebox("This is a sample...", "Message Box Title", function () {  
           alert('custom functions go here');  
   function messagebox(msg, title, func)  
     $("#msgBox").html("<br/>" + msg + "<br/>")  
       resizable: false,  
       modal: true,  
       title: title,  
       width: 400,  
       buttons: {  
         "OK": function () {  
       close: function (event, ui) {  
         if (func) func();  
Categories: Developement, jQuery

©2024 LdnDeveloper