JScript.VBScript use the message box. Dialog - scripting language

2010-08-28  来源:本站原创  分类:Web  人气:195 

The use of JScript message box

-------------------------------------

Use warnings, tips and warnings can be used to confirm, confirm and prompt a message box to get user input. The message box is a window object's interface methods. As the window object is the top-level object hierarchy, thus the actual application need to use the message box's full name (for example, "window.alert ()"), However, the full name is a good idea, Zhe Yang Ji Zhu these messages will help you to box belongs to which object.

Warning message box
alert method has one parameter, that is, users want to display the text string. The string is not HTML. The message box provides an "OK" button allows users to close the message box, and the message box is a modal dialog box, that is, the user must first close the message box before continuing to operate.
window.alert ("Welcome! Please click" OK "to continue.");

The confirmation message box using the confirmation message box may ask a user "is - or - not" problem, and the user can choose to click "OK" button or click "Cancel" button. confirm method returns a value of true or false. The message box is a modal dialog box: the user must respond to the dialog box (click a button) to turn it off before attempting the next step.
var truthBeTold = window.confirm ("Click" OK "to continue. Click" Cancel "to stop.");
if (truthBeTold) (
window.alert ("Welcome to our Web page!");
) Else window.alert ("Good night!");

Prompt message box prompts a message box provides a text field, the user can enter an answer in this field to your prompt response. The message box with an "OK" button and a "Cancel" button. If you provide a secondary string parameter, the prompt message box will be assisted in the text field displays the string as the default response. Otherwise, the default text for the "<undefined>".
And alert () and confirm () method similar, prompt methods will display a message box model. Users must be before continuing to close the message box

var theResponse = window.prompt ("Welcome?", "Please enter your name.");

VBScript to use the message box

-------------------------------------

Use the dialog box for human-computer interaction, the user information or to request user input information, which is commonly used method for various applications. Scripting language also provides such a mechanism, you can pop-up message box in web page, enter the box or the confirmation box, etc..

Objectives and tasks a message box displays a text using

A realization with VBscript

Keyword MsgBox function

Code

<Scripr language = 'VBscript'>
Dim MyVar
MyVar = MsgBox ("Hello World!", 0, "MsgBox example")
</ Script>

Click the button to watch the code run.

Code Notes

MsgBox function pop up a dialog box displays the message in the dialog box. Waiting for the user clicks the button, and returns a value that indicates which button the user clicks on the. Syntax:
xxx = MsgBox (prompt [, buttons] [, title])
Which, prompt as a message to be displayed in the dialog box in the string expression. Is Required. Other parameters are optional. buttons is an integer used to specify the display button and use the number and types of information such as style icons. title string will appear in the message box title bar.

MsgBox function returns an integer value that represents what the user presses the button. With variable MyVar here to receive.

Second, the realization of using Javascript

Keywords warning message box alert

Code

<Scripr language = "javascript">
window.alert ("Welcome to our Web page");
</ Script>

Click the button to watch the code run.

Code Notes

In javascript, you can use the "warning, confirm and prompt" This message box to display three types of information and access to user input. The message box is a window object's interface methods. alert method syntax is
window.alert (string)
It is only a necessary option parameter, use the MsgBox function is not so simple but can be varied. alert method is equivalent to the type MsgBox function buttons parameter is 0 the situation, but there is no return value. Front window also can be omitted.

-------------------------------------------------- ------------------------------

Target task 2 using the input box to receive the user's input

A realization with VBscript

Keyword InputBox function

Code

Dim Input
Input = InputBox ("Enter your name")
MsgBox (Input & "President | President Hello!")

View run results

Code Notes

To obtain the user input can use InputBox function. Its function is displayed in the dialog box prompts language, waiting for the user to enter text or click the button, and returns the contents of the text box. Syntax:
InputBox (prompt [, title] [, default])
Which, prompt is displayed as a cue string in the dialog box is Required. Other parameters are optional. title is the title of input box. default is displayed in the text box as the default value of the response string, if omitted, the text box blank.

Second, the realization of using Javascript

Keywords prompt method

Code

var theResponse = window.prompt ("Welcome?", "Please enter your name.");
window.alert (theResponse);

See the effect of prompt methods:

Code Notes

prompt method for receiving user input a single text, it contains two parameters: the cue and the input box default value. Syntax:
window.prompt ([cue] [, input box default value])
Use with VB's InputBox () similar, InputBox in the cue is a necessary option, but here is optional.

-------------------------------------------------- ------------------------------

3 objectives and tasks for the user to use confirmation box to confirm or deny

Keyword confirm method, if statement

Achieved with Javascript

Code

var truthBeTold = window.confirm ("Click" OK "to continue. Click" Cancel "to stop.");
if (truthBeTold)
window.alert ("You have selected OK");
else window.alert ("You chose Cancel");

Code Notes

confirm Methods dialog box that appears on the "OK" and "Cancel" buttons. It returns a boolean type variable to describe which button the user selects. There are two types of variable boolean values true and false. When the user clicks "OK" button to return true, otherwise returns false. You can return values to construct a branch process, decided to further operation. confirm method syntax:
window.confirm (cue)
Comparison with the alert, alert only displays a button, and there is no return value.

if statement is also known as conditional statements, their syntax has two forms:

Type 1 if (condition) (
Block 1);

Feature is that when the condition condition = true when the implementation of the block 1, otherwise do nothing. condition is a logical expression.

Type 2 if (condition)
1) (statement block;
else
(Block 2);

Feature is that when the condition condition = true when the implementation of the block 1, or the implementation of block 2. It is the two alternatives.

Now, let's take a look at the demo it.

VBscript in order to achieve confirm in the function is very simple, as long as the buttons to take an on-line parameter values, and that truthBeTold = MsgBox ("Choose OK or Cancel", 1).

Javascript dialog with only the above three methods, but use simple; with VBscript the MsgBox () but can create different looks of the message box, and powerful. Here we have to study the MsgBox () of butoons parameter is not what effect the same time in order to understand what purposes they may have.

-------------------------------------------------- ------------------------------

Objectives and tasks 4 shows different types of message box, and verify that the user presses the button value.

Keyword MsgBox message box interface diversity, subroutine, the event handler

Code

Sub B_choice
dim Num, mass, yourpress
mass = "you press the button label is"
Num = InputBox ("Please select a message box type number:" & chr (13) & chr (10) & "0,1,2,3,4,5,
You can also add 16,32,64; or add 256,512,768 ")
yourpress = MsgBox ("demonstration effect of different button", Num)
xxx = MsgBox (mass & yourpress, 0)
End Sub

Code Notes

This code is a subroutine, subroutines with "Sub subroutine name parameter list" to the definition, here is the subroutine name B_choice. By the following "Demo" button to call the book after the procedure. So it is a "click button" event handler. Use the button in the HTML markup language to embed onclick = "B_choice" Help on the line.

Program first pop up a user input box, please select a type number, the result of the choice of keeping the variable Num. Then pop-up buttons = Num type of message box, so users can input different parameters to see the faces of different types of message boxes. Which button the user clicks on the information stored in the variable yourpress, this is a integer value from 0 to 7.

The last statement then a message box that this is an integer value to enable the reader to see which button corresponds to which value.

You can repeatedly click the button to see the true colors of different types of message boxes, so I am long-winded account of buttons meaning for different values of parameters.

相关文章
  • JScript.VBScript use the message box. Dialog - scripting language 2010-08-28

    The use of JScript message box ------------------------------------- Use warnings, tips and warnings can be used to confirm, confirm and prompt a message box to get user input. The message box is a window object's interface methods. As the window obj

  • [ASP.NET] study of small mind (5) pop-up message box 2010-08-15

    Yesterday of how pop-up message box to forward, I can not find C # background limited level of pop-up message box method, only using JS script to package a pop-up effect, today is the day of national mourning, I have three minutes of silence on the C

  • javascript implementation QQ, MSN message box in the bottom right corner of the effect of 2009-06-16

    <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title> Mimics the effect of MSN message prompt </title> <style type="text/css"> a { color: #000; font-s

  • Simulated pop-up message box 2010-08-03

    Simulate a pop-up message box, there are patterns. Core interface is open, the pop-up message box, this method has three parameters, representing the title of the message box, to display the content, the client provides other parameters (parameters s

  • Enter the Chinese in the JSP and saved, there Save could not be completed. Exception message box 2010-09-23

    Enter the Chinese in the JSP and saved, there Save could not be completed. Exception message box Solution: Open the Eclipse's Preferences, select General-> Content Types, And then modify the right of the Text default under the JSP encoding (Default E

  • JQuery pop-up message box 2011-01-05

    JQuery pop-up message box: including pop up a box and more boxes Things in the annex below This is the excerpt of others, only of research

  • Design your own personalized pop up a message box 2011-06-01

    Related links: http://yu123.me/ Design its own pop-up boxes Zuo generally know the front end to minimize the use of alert, mainly because the system of all the pop-up box will terminate the current process, and even with the window operation is also

  • What is a compiled language. Explanatory language and scripting language 2010-03-12

    The computer can not directly understand the high-level language, can only understand machine language directly, it must be high-level language should be translated into machine language, the computer can be value-based high-level language program. T

  • C-based scripting language development technology-csp 2011-05-01

    What is eybuild http://www.eybuild.com/develop/index.htm eyBuild, is short for Easy Build, which is the CSP (C Language Service Page) development kit in general. eyBuild WEB applications on embedded devices is the ideal development tool, with a WEB s

  • JDK6 new features: Scripting language support (Scripting) 2010-03-29

    Overview JDK6 increased its support for scripting languages (JSR 223), theory is the scripting language to compile into bytecode, so scripting languages can also enjoy the Java platform, many advantages, including portability, safety, etc. In additio

  • LUA scripting language entry 2010-03-28

    LUA scripting language entry Preliminary Study Lua Programming: Mu Feng (Second Life members) This article comes from CSDN blog: http://blog.csdn.net/skyremember/archive/2008/10/17/3089447.aspx In this article, I want to tell you how to Lua programmi

  • How to use PHP as a scripting language Shell 2010-12-03

    Many people may have thought about using PHP to write some procedures like regular letters, but no way to time the implementation of PHP; We all know, PHP is a very good dynamic web development languages (speed fast, short development cycle ... ....)

  • Python scripting language is very useful 2010-12-25

    Python scripting language ---------------- very useful Today, do not know which nerve short-circuit, even started to pay attention Python. Internet casually looked down a document, think this thing is too practical it! Might be possible to carefully

  • Strut2 action in the foreground message box pops up 2011-04-27

    copy down as a reference: The first: In struts2 action script in the pop-up message Js For action to achieve ServletResponseAware interface, while achieving its setServletResponse () method import org.apache.struts2.interceptor.ServletResponseAware;

  • javaeye message box div ext 2009-06-20

    <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <link rel="stylesheet" type=&qu

  • Flex in the use of status attribute in the Alert message box to add an example of state information 2010-03-24

    <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white"> <mx:Style> Ale

  • Mode dialog box Dialog background to set the transparency & Dark degree method 2010-04-23

    Reprinted: http://www.eoeandroid.com/thread-12267-1-1.html Set the transparency (the transparency of its own looks like a dialog) WindowManager.LayoutParams lp=dialog.getWindow().getAttributes(); lp.alpha=1.0f; dialog.getWindow().setAttributes(lp); a

  • jQuery UI dialog plugin error message: $ (this). dialog is not a function 2010-09-13

    Use jQuery UI 1.8.4 dialog plugin encountered this error: [Img] http://dl.javaeye.com/upload/attachment/308166/97c428e4-2ce2-367e-b4df-4c4da7686b95.bmp "alt =" "width =" 210 "height =" 44 [/ img] $("#dialog").dialog

  • AlertBox popup (message box) effect 2010-10-11

    Popup window positioning is relative to the document or a layer, generally used to display the message, advertising, etc., but also to lock with the cover page. In imitation Lightbox effect in this effect has been largely achieved, the main improveme

  • Leave a message box to add the expression of js 2010-12-01

    <script type="text/javascript"> <! - / / Function addtext / / Use the contents of the parameter s as a string to the comment box. function addtext (s) { / / Taking into account comments on the page will have a box there, it made direct