Code _ Javascript tips for creating a select File Dialog Box using javascript

Source: Internet
Author: User
Use Javascript to create a dialog box code for selecting files. For more information about CSS styles, see:

The Code is as follows:


DIV. neat-dialog-cont {
Z-INDEX: 98; BACKGROUND: none transparent scroll repeat 0% 0%; LEFT: 0px; WIDTH: 100%; POSITION: absolute; TOP: 0px; HEIGHT: 100%
}
DIV. neat-dialog-bg {
Z-INDEX:-1; FILTER: alpha (opacity = 70); LEFT: 0px; WIDTH: 100%; POSITION: absolute; TOP: 0px; HEIGHT: 100%; BACKGROUND-COLOR: # eee; opacity: 0.7;
}
DIV. neat-dialog {
BORDER-RIGHT: #555 1px solid; BORDER-TOP: #555 1px solid; Z-INDEX: 99; MARGIN-LEFT: 35%; BORDER-LEFT: #555 1px solid; WIDTH: 300px; MARGIN-RIGHT: auto;
BORDER-BOTTOM: #555 1px solid; POSITION: relative; TOP: 25%; BACKGROUND-COLOR: # fff
}
DIV. neat-dialog-title {
PADDING-RIGHT: 0.3em; PADDING-LEFT: 0.3em; FONT-SIZE: 1em; PADDING-BOTTOM: 0.1em; MARGIN: 0px; LINE-HEIGHT: 1.2em; PADDING-TOP: 0.1em; BORDER-BOTTOM: #444
1px solid; POSITION: relative; background: # 36C; color: White;
}
DIV. neat-dialog P {
PADDING-RIGHT: 0.2em; PADDING-LEFT: 0.2em; PADDING-BOTTOM: 0.2em; PADDING-TOP: 0.2em; TEXT-ALIGN: center
}


Javascript code:

The Code is as follows:


// Open the pop-up window
Function f_OpenDialog (){
Var sHTML ='

'+
'

'+
'Cancel

';
New NeatDialog (sHTML, "select an Excel document! ");
}
// Close and remove the pop-up window
NeatDialog. prototype. close = function (){
If (this. elt ){
This. elt. style. display = "none ";
This. elt. parentNode. removeChild (this. elt );
}
Window. neatDialog = null;
}
// Create a pop-up window
Function NeatDialog (sHTML, sTitle ){
Window. neatDialog = null;
This. elt = null;
If (document. createElement & document. getElementById ){
Var dg = document. createElement ("p ");
Dg. className = "neat-dialog ";
If (sTitle)
SHTML ='

'+ STitle +'

\ N' + sHTML;
Dg. innerHTML = sHTML;
Var dbg = document. createElement ("p ");
Dbg. id = "nd-bdg ";
Dbg. className = "neat-dialog-bg ";
Var dgc = document. createElement ("p ");
Dgc. className = "neat-dialog-cont ";
Dgc. appendChild (dbg );
Dgc. appendChild (dg );
If (document. body. offsetLeft> 0 ){
Dgc. style. marginLeft = document. body. offsetLeft + "px ";
}
Document. body. appendChild (dgc );
This. elt = dgc;
Window. neatDialog = this;
}
}


Effect:
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.