What you're asking for is possible in JavaScript, but not on the client side. On the server side you have JavaScript running on RingoJS and node.js.

Ringo can interface with Java packages. So you can essentially using Swing to create GUI applications in JavaScript. For example:

var {FlowLayout} = java.awt;
var {JButton, JFrame, JLabel} = javax.swing;

var frame = new JFrame("Hello World!");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

var contentPane = frame.getContentPane();
contentPane.add(new JLabel("Hello World!"));
contentPane.add(new JLabel("Press Me!"));
contentPane.setLayout(new FlowLayout);

frame.pack();
frame.setVisible(true);

On the client side however you'll need to either use a library to create such dialog boxes for you or roll your own. If you decide to make your own then you'll need to detect the operating system the user is using and style your dialog boxes accordingly.

You'll probably be better off using jQuery UI instead. Plus I don't think it's a good idea to make your web application look like a native application for two reasons:

  1. It won't look the same on all Operating Systems and all configurations. So it's easy to see that you're trying to make it look native which breaks the feel of the website. Instead stick with the theme of your website.
  2. It's easier to just use jQuery UI or some other library of that sort. Anything else is just overkill and a waste of time (at least according to me).
Answer from Aadit M Shah on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-dialogue-boxes
JavaScript Dialogue Boxes - GeeksforGeeks
August 5, 2025 - A dialogue box in JavaScript is a pop-up message that appears on the screen when the user interacts with the webpage.
🌐
TutorialsPoint
tutorialspoint.com › javascript › javascript_dialog_boxes.htm
JavaScript - Dialog Boxes
This dialog box is displayed using a method called prompt() which takes two parameters: (i) a label which you want to display in the text box and (ii) a default string to display in the text box.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › HTML › Reference › Elements › dialog
The Dialog element - HTML - MDN Web Docs - Mozilla
February 19, 2026 - The HTML <dialog> element is used to create both modal and non-modal dialog boxes. Modal dialog boxes block interaction with other UI elements, making the rest of the page inert, while non-modal dialog boxes allow interaction with the rest of the page. JavaScript can be used to display and ...
🌐
C# Corner
c-sharpcorner.com › UploadFile › 26b237 › dialog-box-in-javascript
Dialog Boxes in JavaScript
March 22, 2023 - When you click on the "OK" button, it will show in the browser. This dialog box is mainly used for confirming the user of specific actions. When you are exiting from a window, then it could request confirmation from the user, like "Do you want to Exit?", It displays two buttons on the dialog box: "OK" and "Cancel". When you click the "OK" button, it returns true. Otherwise, it returns false. The following is an example of a confirmation dialog box, <!DOCTYPE html> <html> <title>JavaScript Dialog Box</title> <head></head> <body> <script language="javascript"> var t = confirm("Do you really want to Exit?"); if(t == true) { document.write("Thanks for using"); } else { document.write("Welcome To C# Corner"); } </script> </body> </html>
🌐
W3Schools
w3schools.com › js › js_popup.asp
JavaScript Popup Boxes
JS Examples JS HTML DOM JS HTML Input JS HTML Objects JS HTML Events JS Browser JS Editor JS Exercises JS Quiz JS Website JS Syllabus JS Study Plan JS Interview Prep JS Bootcamp JS Certificate JS Reference ... An alert box is often used if you want to make sure information comes through to the user.
Top answer
1 of 4
3

What you're asking for is possible in JavaScript, but not on the client side. On the server side you have JavaScript running on RingoJS and node.js.

Ringo can interface with Java packages. So you can essentially using Swing to create GUI applications in JavaScript. For example:

var {FlowLayout} = java.awt;
var {JButton, JFrame, JLabel} = javax.swing;

var frame = new JFrame("Hello World!");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

var contentPane = frame.getContentPane();
contentPane.add(new JLabel("Hello World!"));
contentPane.add(new JLabel("Press Me!"));
contentPane.setLayout(new FlowLayout);

frame.pack();
frame.setVisible(true);

On the client side however you'll need to either use a library to create such dialog boxes for you or roll your own. If you decide to make your own then you'll need to detect the operating system the user is using and style your dialog boxes accordingly.

You'll probably be better off using jQuery UI instead. Plus I don't think it's a good idea to make your web application look like a native application for two reasons:

  1. It won't look the same on all Operating Systems and all configurations. So it's easy to see that you're trying to make it look native which breaks the feel of the website. Instead stick with the theme of your website.
  2. It's easier to just use jQuery UI or some other library of that sort. Anything else is just overkill and a waste of time (at least according to me).
2 of 4
2

You can still use jQuery modals (or whatever JS modals) but you could skin them according to the user's platform. However, UA detection can easily be spoofed, especially with abundant extensions and dev tools.

In addition, JS has no jurisdiction beyond the 4 sides of the viewport (unless you get leverage from browser extensions/plugins, an additional hassle and most of the time limited). You can't call native operations with JS directly.

All in all, I'd say it's possible, but very tricky.

🌐
e-Adhyayan
ebooks.inflibnet.ac.in › itp9 › chapter › dialog-boxes-in-javascript
Dialog Boxes in JavaScript – Web Application Development- II
JavaScript provides three types of pop-up dialog boxes for giving feedback and retrieving user-entered data using methods of window object for use in your applications.
Find elsewhere
Top answer
1 of 10
65

I encountered the same issue (dialog would only open once, after closing, it wouldn't open again), and tried the solutions above which did not fix my problem. I went back to the docs and realized I had a fundamental misunderstanding of how the dialog works.

The $('#myDiv').dialog() command creates/instantiates the dialog, but is not necessarily the proper way to open it. The proper way to open it is to instantiate the dialog with dialog(), then use dialog('open') to display it, and dialog('close') to close/hide it. This means you'll probably want to set the autoOpen option to false.

So the process is: instantiate the dialog on document ready, then listen for the click or whatever action you want to show the dialog. Then it will work, time after time!

<script type="text/javascript"> 
        jQuery(document).ready( function(){       
            jQuery("#myButton").click( showDialog );

            //variable to reference window
            $myWindow = jQuery('#myDiv');

            //instantiate the dialog
            $myWindow.dialog({ height: 350,
                width: 400,
                modal: true,
                position: 'center',
                autoOpen:false,
                title:'Hello World',
                overlay: { opacity: 0.5, background: 'black'}
                });
            }

        );
    //function to show dialog   
    var showDialog = function() {
        //if the contents have been hidden with css, you need this
        $myWindow.show(); 
        //open the dialog
        $myWindow.dialog("open");
        }

    //function to close dialog, probably called by a button in the dialog
    var closeDialog = function() {
        $myWindow.dialog("close");
    }


</script>
</head>

<body>

<input id="myButton" name="myButton" value="Click Me" type="button" />
<div id="myDiv" style="display:none">
    <p>I am a modal dialog</p>
</div>
2 of 10
25

Looks like there is an issue with the code you posted. Your function to display the T&C is referencing the wrong div id. You should consider assigning the showTOC function to the onclick attribute once the document is loaded as well:

$(document).ready({
    $('a.TOClink').click(function(){
        showTOC();
    });
});

function showTOC() {
    $('#example').dialog({modal:true});
}

A more concise example which accomplishes the desired effect using the jQuery UI dialog is:

   <div id="terms" style="display:none;">
       Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
   </div>
   <a id="showTerms" href="#">Show Terms &amp; Conditions</a>      
   <script type="text/javascript">
       $(document).ready(function(){
           $('#showTerms').click(function(){
               $('#terms').dialog({modal:true});   
           });
       });
   </script>
🌐
Medium
khaisastudio.medium.com › a-beginner-guide-to-javascript-dialog-boxes-alert-prompt-and-confirm-f37953d0bf74
A Beginner Guide to JavaScript Dialog Boxes: alert, prompt, and confirm | by Khairul Muhtadin | Medium
November 23, 2024 - JavaScript provides three simple dialog boxes — alert, prompt, and confirm—to interact with users. While they’re basic, they’re also incredibly useful for quick and straightforward user communication.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › HTML › Element › dialog
<dialog>: The Dialog element - HTML - MDN Web Docs - Mozilla
The HTML <dialog> element is used to create both modal and non-modal dialog boxes. Modal dialog boxes block interaction with other UI elements, making the rest of the page inert, while non-modal dialog boxes allow interaction with the rest of the page. JavaScript can be used to display and ...
🌐
Shaalaa
shaalaa.com › question-bank-solutions › explain-about-the-popup-dialog-boxes-in-javascript_230349
Explain about the popup dialog boxes in JavaScript. - Computer Applications | Shaalaa.com
July 1, 2021 - JavaScript supports three kind of popup boxes: Alert box, Confirm box, and Prompt box. ... An alert dialog box is mostly used to give a warning message to the users. For example, if one input field requires entering some text but the user does ...
🌐
Webassembly
webassembly.fr › en › javascript › alert.php
Dialog box or alert message in JavaScript
<form name="form3" > <input name="prompt3" type="text" value="Your answer?"> <input name="prompt4" type="text" value="Initial value..."> <input type="button" value="Send" onclick="alert(prompt( document.form3.prompt3.value, document.form3.prompt4.value))"> </form>
🌐
Ducat India
tutorials.ducatindia.com › javascript › javaScript-dialog-boxes
Javascript Tutorial - JavaScript Dialog Boxes
Discover comprehensive JavaScript Dialog Boxes tutorials at Ducat India. Learn to create alert, prompt, and confirm boxes with hands-on examples. Start mastering JS now!
🌐
JavaScript in Plain English
javascript.plainenglish.io › build-a-dialog-box-with-dialog-efb08952551d
Build a Dialog Box with <dialog /> Element | JavaScript in Plain English
October 4, 2022 - In this article, we’ll see the challenge of building a dialog and then see whether there’s an easy way. ... There’s a button, if we click it we open a dialog box. We can apply some CSS code so that the dialog looks like popping out of the screen, and we might have to use some JavaScript code to trigger the open event.
🌐
Medium
medium.com › @muhamedsalihseyedibrahim › javascript-dialog-boxes-b77d7c7674c4
JavaScript — Dialog Boxes
July 7, 2023 - It displays a message along with an input field for the user to enter data. The prompt dialog box has two buttons: OK and Cancel. If the user clicks OK after entering a value, the prompt() function returns the entered value as a string.
🌐
W3docs
w3docs.com › javascript
How to Create a Modal Dialog Box with CSS and JavaScript
The final step is to add JavaScript in our code. We can add the function either in the <head> of our document or in an external .js file. function example() { el = document.getElementById("example"); el.style.visibility = (el.style.visibility == "visible") ? "hidden" : "visible"; } We use an automatic toggle method to make it visible if it is hidden. We should add the following on our page so when the user clicks on the link our box will be shown.
🌐
Coderepublics
coderepublics.com › JavaScript › JavaScript-window-dialog-boxes.php
JavaScript Dialog Box - Alert, Prompt and Confirm
July 5, 2021 - An alert dialog box displays a short message or notification to the user. It includes only an OK button. It just give some information, necessary to the user and it can be invoked at various events possible in javascript.
🌐
Quora
quora.com › What-are-dialog-boxes-in-Javascript
What are dialog boxes in Javascript? - Quora
Answer (1 of 2): Three types of dialog boxes ALERT dialog box:An alert dialog box is mostly used to give a warning message to the user. CONFIRMATION dialog box: A confirmation dialog box is mostly used to take user's consent on any option.