<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.4/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.13.2/jquery-ui.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.13.2/themes/smoothness/jquery-ui.min.css">
<body>
<input type="button" id="showDialog" value="Show Dialog" />
<input type="button" id="showModalDialog" value="Show Modal Dialog" />
<div id="content">
the following content will be displayed in the dialog:<br />
Because JavaScript is the language of the web browser, and because the web browser has become the dominant application delivery system, and because JavaScript isn't too bad, JavaScript has become the World's Most Popular Programming Language. Its popularity is growing. It is now being embedded in other applications and contexts. JavaScript has become important.
</div>
<pre id="results">Not Imported [4]
DYNAMIC_ALLOCATION_ENABLED_64_128
DYNAMIC_ALLOCATION_MAX_128
DYNAMIC_ALLOCATION_MAX_256
DYNAMIC_ALLOCATION_MAX_512
Imported...
/**
* the purpose of the following code is to give a demo of
* how to realize the floating dialog using javascript.
* It was written without any consideration of cross-browser compatibility,
* and it can be run successfully under the firefox 3.5.7.
*/
var Samples = {};
/**
* to show a floating dialog displaying the given dom element
* @param {Object} title "title of the dialog"
* @param {Object} element "the element will be set as content of the dialog"
* @param {Object} modal "whether to make a modal dialog"
* @param {Object} callback "callback function for the dialog closed"
*/
Samples.dialog = function (title, element, modal, callback) {
if (!element) {
throw 'the elment must be specified';
}
// initializing dialog: title, close, content
var container = document.createElement('div');
var titleContainer = document.createElement('div');
var contentContainer = document.createElement('div');
var closeContainer = document.createElement('span');
container.setAttribute('id', 'sampleDialog');
titleContainer.setAttribute('id', 'title');
closeContainer.setAttribute('id', 'close');
contentContainer.setAttribute('id', 'dialog-content');
titleContainer.innerHTML = title;
closeContainer.innerHTML = 'X';
container.appendChild(titleContainer);
contentContainer.appendChild(element);
container.appendChild(contentContainer);
container.appendChild(closeContainer);
document.body.appendChild(container);
// place the container in the center of the browser window
window.center(container);
closeContainer.style.left = container.offsetWidth - 20 + 'px';
if (modal) {
var overlay = document.createElement('div');
overlay.setAttribute('id', 'overlay');
document.body.appendChild(overlay);
container._overlay = overlay;
}
// binding mouse events
closeContainer.onclick = function (evt) {
if (container._overlay) {
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.