On the _javascript techniques of three kinds of windows in JavaScript

Source: Internet
Author: User

Three kinds of window in JS

1Alert pop-up warning no return value---------alert (' first row \ second row ');

2confirm () Select OK or cancel, return t or f----var result = confirm (' Delete! ');

3)prompt () pop-up input box, return the input content----var value = Prompt (' Enter your name: ', ' Please enter the name here ');

Of course, you can also customize the good-looking style. There is a problem with the following code tomorrow.

<script>//window.confirm//prompt window.alert = function (title,str) {var shield = document.createelement ("DIV" 
); 
Shield.id = "shield"; 
Shield.style.position = "absolute"; 
Shield.style.left = "0px"; 
Shield.style.top = "0px"; 
Shield.style.width = "100%"; 
Shield.style.height = document.body.scrollheight+ "px"; 
Pop-up dialog box when the background color shield.style.background = "#fff"; 
shield.style.textAlign = "center"; 
Shield.style.zIndex = "25"; 
Background transparent ie effective//shield.style.filter = "alpha (opacity=0)"; 
var Alertfram = document.createelement ("DIV"); 
Alertfram.id= "Alertfram"; 
AlertFram.style.position = "absolute"; 
AlertFram.style.left = "50%"; 
AlertFram.style.top = "50%"; 
AlertFram.style.marginLeft = " -225px"; 
AlertFram.style.marginTop = " -75px"; 
AlertFram.style.width = "450px"; 
AlertFram.style.height = "150px"; 
AlertFram.style.background = "#ff0000"; 
alertFram.style.textAlign = "center"; 
AlertFram.style.lineHeight = "150px"; 
AlertFram.style.zIndex = "300"; strhtml = "<ul style=\"List-style:none;margin:0px;padding:0px;width:100%\" >\n "; strHTML + = "<li style=\" background: #DD828D; text-align:left;padding-left:20px;font-size:14px;font-weight:bold; 
height:25px;line-height:25px;border:1px solid #F9CADE; ">" + title + "</li>\n"; strHTML + = "<li style=\" background: #fff; text-align:center;font-size:12px;height:120px;line-height:120px; 
BORDER-LEFT:1PX solid #F9CADE border-right:1px solid #F9CADE; ">" + str + "</li>\n"; strHTML + = "<li style=\" background: #FDEEF4; text-align:center;font-weight:bold;height:25px;line-height:25px; 
border:1px solid #e85727; \ "><input type=\" button\ "value=\" OK \ "Onclick=\" Dook () \ "/></li>\n"; 
strHTML + = "</ul>\n"; 
alertfram.innerhtml = strhtml; 
Document.body.appendChild (Alertfram); 
Document.body.appendChild (shield); 
var ad = SetInterval ("Doalpha ()", 5); 
This.dook = function () {AlertFram.style.display = ' none '; 
Shield.style.display = "None"; 
} alertfram.focus (); Document.body.onselEctstart = function () {return false;}; } </script>

The above is a small series for everyone to talk about the JavaScript in the three kinds of bullet window all content, I hope that we support cloud-Habitat Community ~

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.