Javascript implementation dialog box

Source: Internet
Author: User

the alert prompt confirm dialog box is usually used.

<HTML> <br/> <pead> <br/> <title> simple example dialog box </title> <br/> </pead> <br/> <body> <br/> <MCE: script Type = "text/JavaScript"> <! -- </P> <p> alert ("good morning! "); <Br/> // alert only accepts one parameter, which is a string, all alert does is return this string to the user in a prompt box, we have seen this usage many times before <br/> alert ("hello," + prompt ("What's your name? ") + "! "); <Br/> // prompt is a query box that generates a query input window, wait for the user input result <br/> // to continue executing the following <SPAN class = 'wp _ keywordlink '> Program </span>. When the user input is complete, after you click OK, it returns the input string <br/> // if the user clicks the cancel button, then it will return NULL <br/> If (confirm ("are you OK? ") <Br/> // confirm is a confirmation box that generates a Yes | no confirmation box. If yes is answered, it returns true <br/> // if no is answered, it returns false <br/> alert ("greate! "); <Br/> else <br/> alert (" Oh, what's wrong? "); <Br/> // --> </MCE: SCRIPT> <br/> </body> <br/>

 

You can also define a new window simulation dialog box

<HTML> <br/> <pead> <br/> <title> example simulation dialog box </title> <br/> </pead> <br/> <body> <br/> <button onclick = "opennew () "> open </button> <br/> <MCE: Script Type =" text/JavaScript "> <! -- <Br/> function opennew () {<br/> // doucment. createelement can be used to construct a new DOM object <br/> var W = document. createelement ("Div "); </P> <p> // the following set of style attributes control the style of the simulated window <br/> // The style attribute provided by Dom makes it easy for JavaScript to Control Element display Mode </P> <p> W. style. top = 50; <br/> W. style. left = 50; <br/> W. style. height = 100; <br/> W. style. width = 300; <br/> W. style. position = "absolute"; <br/> W. style. background = "#00 FFFF"; <br/> W. style. paddingtop = 10; </P> <p> // Add the created Div Element Object to the body content using the appendchild () method. <br/> W. innerhtml + = ("<center> I & nbsp; D & nbsp;: <input> <br> password: <input> <br> </center> "); <br/> document. body. appendchild (w); <br/>}< br/> // --> </MCE: SCRIPT> <br/> </body> <br/> </ptml>

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.