Custom dialog box implemented with JQuery_jquery
May 16, 2016 pm 07:16 PMJavaScript provides us with several dialog box functions, but the functions are very limited; although richer dialog box functions can be created through modal forms under IE, after all, only IE is supported. In order to get richer custom dialog box functions, I wrote a dialog box plug-in using JQuery; you can get rich custom dialog box functions by simply quoting the relevant JavaScript.
Plug-in features:
Allows appearance control through CSS.
You can display any element of the page as a dialog box.
When the dialog box is activated, any elements outside the dialog box cannot accept mouse operations.
The dialog box can be moved arbitrarily within the work area, and the centering function is adaptive according to the size of the work area.
There is no need to write complex JavaScript, just describe it through simple HTML attributes.
The plug-in has been tested and can work normally under Firefox and IE.
Simple usage description:
Reference to JQuery and dialog plug-in files:
;/script>
Define the relevant button as a row:
Define the content displayed in the relevant dialog box:
if(option.parent)
(document.body).append(html); css,region;
region = GetDocumentRegion();
css ={width:region.width "px",height:region.height "px",
left: MessageBox_scrollleft 'px',top: MessageBox_scroll top 'px'}
GetOpacity(css);
$("#messagebox_enabled").css(css);
$("#messagebox_enabledframe").css(css);
} 🎜 > //Set transparent style
function GetOpacity(css)
{
if(window.navigator.userAgent.indexOf('MSIE')>=1)
{ css.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=30)';
}
}
//Set dialog sample
function SetStyle(option)
{
var region,css;
region = GetDocumentRegion();
css = {width:MessageBox_width 'px',height :MessageBox_height 'px',
left: ((region.width - MessageBox_width)/2) 'px',top: ((region.height - MessageBox_height)/2) 'px'}
if(region. height < MessageBox_height )//If the height of the body display is less than the height of the dialog box
🎜> css.top =((region.height - MessageBox_height)/2) 'px'
} }
$('#messagebox_win').css(css);
css.top='0px';
css .left='0px';
$('#messagebox_table') .css(css); ('#messagebox_title_td').css(css);
var down_x,down_y,cx,cy;
function handleMouseDown(e)
{
var evt = e || event;
down_x=evt.clientX;
down_y = evt.clientY;
cx =(parseInt(MessageBox_win.css('left'))|0);
cy = (parseInt(MessageBox_win.css('top'))|0)
MessageBox_Moving= true;3
document.documentElement.onselectstart = function(){return false};
document.documentElement.ondrag = function(){return false};
document.onmousemove = handleMouseMove;
$(document.body).append('');
$('#messagebox_move').css('width',MessageBox_win.css('width'));
$('#messagebox_move').css('height',MessageBox_win_u99 ?ss('height'));
$('#messagebox_move').css('left',MessageBox_win.css('left'));
$('#messagebox_move').css('top',MessageBox_win.css('top'));
}
function GetDocumentRegion()
{
var w,h,de;
de = document.documentElement;
w = self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
h = self.innerHeight || (de&&de.clientHeight)|| document.body.clientHeight;
return {height:h,width:w};
}
function handleMouseMove(e)
{
var left,top,region;
if (MessageBox_Moving)
{
var evt = e || event;
left =evt.clientX cx-down_x;
top = evt.clientY cy-down_y;
region = GetDocumentRegion();
if(left MessageBox_width > region.width)
{
left = region.width - 10- MessageBox_width;
}
if(top MessageBox_height >region.height)3
{
top = region.height-10 - MessageBox_height;
}
if(left <10)
left =10;
if(top <10)
top =10;
var css ={left:left 'px',top:top 'px'}
$('#messagebox_move').css(css);
}
}
function handleMouseUp()
{
if(MessageBox_Moving)
{
MessageBox_win.css('width',$('#messagebox_move').css("width"));
MessageBox_win.css('height',$('#messagebox_move').css("height"));
MessageBox_win.css('left',$('#messagebox_move').css("left"));
MessageBox_win.css('top',$('#messagebox_move').css("top"));
}
MessageBox_Moving _u61 ? false;
document.onmousemove = null;
$('#messagebox_move').remove();
}
}
//Close mode Dialog box
function CloseMessageBox()
{
if(MessageOninit)
{
$('#messagebox_win').hide();
$('#messagebox_enabled'). remove();
$('#messagebox_enabledframe').remove();
Messagebox_AC.css('display','none');
MessageBox_PC.append(Messagebox_AC);
}
document.documentElement.onselectstart = null;
document.documentElement.ondrag = null;
}
$(document).ready(function(){
$(document).find(' [@showoption]').each(function(){
var namevalue;
var option ={control:'',width:'400',height:'400',title:'',parent:null};
var properties = $(this).attr('showoption').split(' ;');
for(i=0;i
$(this).click(function(){
ShowMessageBox(option);
document.body.focus();
});
});
}) ;

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Frequently Asked Questions and Solutions for Front-end Thermal Paper Ticket Printing In Front-end Development, Ticket Printing is a common requirement. However, many developers are implementing...

JavaScript is the cornerstone of modern web development, and its main functions include event-driven programming, dynamic content generation and asynchronous programming. 1) Event-driven programming allows web pages to change dynamically according to user operations. 2) Dynamic content generation allows page content to be adjusted according to conditions. 3) Asynchronous programming ensures that the user interface is not blocked. JavaScript is widely used in web interaction, single-page application and server-side development, greatly improving the flexibility of user experience and cross-platform development.

There is no absolute salary for Python and JavaScript developers, depending on skills and industry needs. 1. Python may be paid more in data science and machine learning. 2. JavaScript has great demand in front-end and full-stack development, and its salary is also considerable. 3. Influencing factors include experience, geographical location, company size and specific skills.

Learning JavaScript is not difficult, but it is challenging. 1) Understand basic concepts such as variables, data types, functions, etc. 2) Master asynchronous programming and implement it through event loops. 3) Use DOM operations and Promise to handle asynchronous requests. 4) Avoid common mistakes and use debugging techniques. 5) Optimize performance and follow best practices.

Discussion on the realization of parallax scrolling and element animation effects in this article will explore how to achieve similar to Shiseido official website (https://www.shiseido.co.jp/sb/wonderland/)...

The latest trends in JavaScript include the rise of TypeScript, the popularity of modern frameworks and libraries, and the application of WebAssembly. Future prospects cover more powerful type systems, the development of server-side JavaScript, the expansion of artificial intelligence and machine learning, and the potential of IoT and edge computing.

How to merge array elements with the same ID into one object in JavaScript? When processing data, we often encounter the need to have the same ID...

In-depth discussion of the root causes of the difference in console.log output. This article will analyze the differences in the output results of console.log function in a piece of code and explain the reasons behind it. �...
