JavaScript click on the button to eject the transparent floating layer method _javascript tips

Source: Internet
Author: User

The example in this article tells you how to eject a transparent floating layer after the JavaScript click button. Share to everyone for your reference. The specific analysis is as follows:

Click here to realize the page after the gray, and JS pop-up a center floating layer Hint window, this window is transparent, you can set the transparency, the Internet has a lot of similar JavaScript code, you can learn from.

<HTML> <HEAD> <TITLE> Floating Layer Center dialog box Effect demo </TITLE> <meta http-equiv=content-type content= "text/ html Charset=utf-8 "> <style type=text/css> HTML {height:100%} body {height:100%} body {font-size:14px; Font-family:tahoma, Verdana, Sans-serif} 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:auto;
 Border-left: #555 1px solid; width:30%; 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:0.8em; Padding-bottom:0.1em; margin:0px; Line-heIght:1.2em; Padding-top:0.1em; Border-bottom: #444 1px solid; Position:relative} img.nd-cancel {right:0.2em; Position:absolute; TOP:0.2EM} div.neat-dialog P {padding-right:0.2em;
 Padding-left:0.2em; Padding-bottom:0.2em; Padding-top:0.2em; Text-align:center} </STYLE> <script type=text/javascript> function Neatdialog (SHTML, Stitle, bcancel) {win
 Dow.neatdialog = null;
 This.elt = null;
 if (document.createelement && document.getElementById) {var dg = document.createelement ("div");
 Dg.classname = "Neat-dialog";
  if (stitle) SHTML = ' <div class= ' neat-dialog-title ' > ' +stitle+ ((bcancel)?
 '  ':" "+ ' </div>\n ' + SHTML;
 dg.innerhtml = SHTML;
 var dbg = document.createelement ("div");
 Dbg.id = "ND-BDG";
 Dbg.classname = "NEAT-DIALOG-BG";
 var DGC = document.createelement ("div");
 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);
 if (bcancel) document.getElementById ("Nd-cancel"). onclick = function () {window.neatDialog.close ();
 };
 This.elt = DGC;
 Window.neatdialog = this;
 } NeatDialog.prototype.close = function () {if (this.elt) {this.elt.style.display = ' none ';
 This.elt.parentNode.removeChild (This.elt);
} Window.neatdialog = null; The function OpenDialog () {var SHTML = ' <p> What you see now is a layer window, which is the </p> ' + ' <p><button onclick= ' windows that is ejected by JS control
 . Neatdialog.close () "> Close </button></p>"; New Neatdialog (SHTML, "Do you know?)
", false); </SCRIPT> <BODY> <H1> Floating Layer Center effect </H1> <button onclick=opendialog () > Point this demo effect </button > </BODY> </HTML>

The

wants this article to help you with your JavaScript programming.

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.