网页(二版)第章(Web pages (two edition) seventh chapters).doc

上传人:rrsccc 文档编号:8911536 上传时间:2021-01-24 格式:DOC 页数:10 大小:34KB
返回 下载 相关 举报
网页(二版)第章(Web pages (two edition) seventh chapters).doc_第1页
第1页 / 共10页
网页(二版)第章(Web pages (two edition) seventh chapters).doc_第2页
第2页 / 共10页
网页(二版)第章(Web pages (two edition) seventh chapters).doc_第3页
第3页 / 共10页
网页(二版)第章(Web pages (two edition) seventh chapters).doc_第4页
第4页 / 共10页
网页(二版)第章(Web pages (two edition) seventh chapters).doc_第5页
第5页 / 共10页
点击查看更多>>
资源描述

《网页(二版)第章(Web pages (two edition) seventh chapters).doc》由会员分享,可在线阅读,更多相关《网页(二版)第章(Web pages (two edition) seventh chapters).doc(10页珍藏版)》请在三一文库上搜索。

1、网页(二版)第7章(Web pages (two edition) seventh chapters)This article is contributed by qinghengrenPpt documents may experience poor browsing on the WAP side. It is recommended that you first select TXT, or download the source file to the local view.Webpage making and ApplicationThe seventh chapter uses V

2、BScript in web pages for use in web pagesThis chapter aims at learning1. VBScript concepts, 2. VBScript data types and variables, 3. VBScript various statements, 4. VBScript sub processes and function processes, 5. VBScript events and form validation7.1 brief introduction of JavaScriptVBScript is a

3、scripting language, introduced by MicroSoft, a simplified version of the Basic Visual language, and the default programming language for ASP. You can embed the VBScript script directly in the HTML file and perform its functionality in the standard HTML by embedding or calling the method. VBScript ca

4、n be interpreted as a client programming language that is interpreted by browsers, thereby reducing server load. VBScript can also serve as a server-side programming language that performs all operations on the server without browser restrictions.VBScript program format, VBScript program format(1) V

5、BScript code is enclosed with HTML tags and can be inserted anywhere in the HTML document. (2) basic format: the function is that when the browser does not support VBScript, the script is not processed, and the IE browser does not need to add. (3) the comment statement is a single foreign quotation

6、mark, and the part behind the single quotation marks is not executed.Data types, variables, 7.2 data types, variables, constants, and array 1. data typesIn VBScript, there is only one generic data type, that is, the variant type, whose subtype contains all base data types. In practice, the program s

7、elects a suitable type for conversion as needed, and the subtype can be viewed with the function vartype.Common operator 2. commonly used operator(1) arithmetic operators: the power () and negative (-), multiplication and division (*) (/), integer division (), modulo (MOD) and addition (+) and minus

8、 (-). (2) the relational operators: equal to (=), () is not equal to, less than, less than or equal to () (), greater than, greater than or equal to the (). (3) logical operators: logical, non (not), logical and (and), logical, or (or). (4) string concatenation operators: + number and & number. Prio

9、rity: (1) arithmetic operator connection operator comparison operator logical operator (2), the same level operation is proceeding from left to right. (3) the operations in parentheses always take precedence over operations outside parentheses.The 3. declaration declares the VBScript variable variab

10、leVariables are actually a small area of memory in which variables are used to temporarily store data and to call or modify data in variables through variable names. There are 2 kinds of explicit declarations and implicit declarations. Explicitly declare variables using dim, public, and private stat

11、ements, and multiple variable names separated by commas. For example: dim, TT, as, integer, public, as, integer, A2, as, string, private, A1, A1, A2, A3, implicitly declared variables, omitted variable declarations, directly assigned a value to a variable name, implicitly declares variables. This me

12、thod allows you to identify variable names with variable values.Variable name naming rules (1) first characters must be letters, and variables cannot include punctuation marks. (2) the length of a variable name must not exceed 255 characters, preferably within 32 characters. (3) the same process var

13、iable name must be unique, variable process can be the same. (4) the variable name cannot be the same name as the keyword. Explanation: VBScript variable names are case insensitive, and usually variable names are lowercase letters.An array of 4. is a set of variables with the same name and different

14、 subscript, and the index element of the array is unique. For example, a (5), where a is an array name and 5 is an index. Arrays must be declared before they are used. The declaration contents include array names, array elements, and array element types. The subscript of the VBScript array starts at

15、 0. For example, dim a (8) declares a one-dimensional array with a total of 9 elements, and the maximum index of the array element is 8. Dim b (3,5) declares a two-dimensional array with a total of 24 elements.5. symbolic constantsA symbolic constant is a name with a fixed value used to represent st

16、rings, numbers, and other constants. Constants, once declared, remain the same throughout the execution of the script. Change the value of a constant by simply changing the constant declaration. Defines a symbolic constant, with the const statement, which specifies the symbol constant name in upperc

17、ase letters to distinguish it from the variable name. For example: const X= signed constantSeven point threeformatSentence structureThe if-then-e1se statement if-then-e1se statement if 1. then statements sequence 1 else statement sequence 2 end first calculate whether the conditions established, if

18、the condition is true (up) the statement following the sequence 1, if the condition is false (not true) performs a sequence of statements 2. A condition is usually a relational expression. IfExample: determine the size of the two numbers.2., select, case, multiple choice statements, multiple-choice

19、statementsFormat select, case, case, case. Case n: n n+1 case statement sequence statement sequence else:end select first expressions, then each case expression results in the structure are compared, if a match value of the block is executed with the case Association, if there is no match value of t

20、he block is executed after the else case. Expression statement sequence 1 statement sequence 2 value 1: value 2:Example: after using the script, it can be empty.3. doformatLoop loop statement, while, -loop, loop statementDo while loop conditional statement sequence loopThe function program first che

21、cks whether the condition is set, and if the condition is true, execute the sequence of statements. When you encounter a loop statement, return to the beginning of the loop, and then again, if the condition is true, execute the statement sequence again. When the condition is false, exit the loop. No

22、te (1) the do while-loop loop first determines the subsequent execution and continues the loop when the condition is true. (2) if you change while to until, you change to do until-loop, and when the condition is true, the loop ends.Give an example:The setting condition is always trueFor4. for-next l

23、oop statementThe for-next loop enables the statement sequence to run a specified number of times, and there is a counter variable in the for loop that increases or decreases with each cycle. For next the initial format function is assigned to the variable, then the loop variable current value and fi

24、nal value comparison, if the comparison is true execution sequence, and then add a step and then compare, if the comparison is true to cycle. If the result of the comparison is false, the loop is ended. Loop variable = initial value statement, sequence to, final value, step step sizeNote (1) if the

25、step size is positive, then the current value of the loop variable is determined to be greater than the final value. If the step size is negative, the current value of the loop variable is judged to be smaller than the final value. The step length of 0 causes the loop to end, so the step size is not

26、 set to 0. (2) the step length can be integer or decimal, and the step length can be omitted when it is 1. (3) the for loop can be nested. (4) in the for loop, the exit for statement can be used to abort the loop.For example (for all primes within 100), the following is a prime number within 100:giv

27、e 2100 all of the numbers one by one. verify that the current number is prime.exit for forced the cycle to stopFiveForfor-each loop statementFor each. The in loop is used to iterate through each element of an array or collection of objects. The format for next functions iterate over each element of

28、an array or collection of objects in cyclic variables. The value of the loop variable is executed every time the statement sequence is executed until the end of the traversal. Note (1) if you dont know how many elements a collection has, its very convenient to use the for each loop. (2) the for each

29、 statement does not need to specify the number of cycles, and each element is traversed only once. Each loop variables, statements, sequences, in sets, or arraysFor example (for all odd numbers within 50), the following are all odd numbers within 50:Assign an arraySeven point fourProcess and functio

30、nA process is a single piece of program code that performs specific tasks that can be called repeatedly, and is the main way to connect scripts and form objects on the web page. In VBScript, the process is divided into two classes based on whether or not the value is returned: the Sub process and th

31、e Function process. The Sub procedure does not return values, so it cannot be used in expressions. The Function function returns results after execution, and is often used in expressions.1. sub processWhen calling the sub procedure, only the operations are performed and no values are returned. Defin

32、e the sub procedure format, sub procedure name (parameter 1, parameter 2,.) The statement sequence End Sub calls the sub procedure format format, the 1:call procedure name (argument 1, argument 2,.) 2: the 1 format process, argument 2,. Note (1) the arguments are separated by commas. If the sub proc

33、edure has no arguments, it must also contain parentheses. (2) the arguments in the calling process can be constants, variables, or expressions that have been assigned. (3) a parameter can only be the name of a variable.(4)使用退出语句可以立即从子过程中退出。举例:2。功能过程功能过程调用功能过程时通过函数名返回一个值。定义功能过程格式功能过程名(形参形参1,2,)语句序列过程

34、名=表达式.端功能调用功能过程格式调用功能过程直接引用过程名。说明(1)功能过程使用方法与内置函数大致相同。(2)实参可以是常数、已赋值的变量或表达式。(3)如果过程无参数,也必须包含空括号。(4)使用退出功能语句可以立即从功能过程中退出。举例:“调用功能过程”空几个格”定义功能过程三.在过程调用中传值与传地址当形参与实参都是变量名时就会有两种参数传递方式:传值与传地址。(1)按地址传递按地址传递是把实参的地址传给形参,这样形参与实参代表的是同一个存储区域,如果在过程中改变了形参的值,实参变量的值也发生相同的改变。按地址传递是参数传递的默认方式,用关键字ByRef表示。(2)按值传递按值传递是

35、把实参的值传给形参,传递的只是实参变量的副本,形参与实参各自代表不同的存储区域,如果在过程中改变了形参的值,不会影响到实参变量本身按值传递的关键字是ByVal。4。内置函数7类:数学函数、格式转换函数、日VBScript内置函数大至分为期/时间函数、输入输出函数、字符串操作函数、变体子类型函数、数组操作函数,函数名不区分大小写。(1)输入函数InputBox格式:InputBox(“提示信息”、“标题栏字串”,默认值)(2)输出函数MsgBox格式:MsgBox(“提示信息”,按钮数目与图标类型,“标题栏字串”)7.5事件与表单1。常用事件(1)负荷,加载窗口或框架。(2)卸下,关闭窗口或框架。(3)单击,鼠标单击。(4)dbclick,鼠标双击。(5)重点,得到鼠标或焦点。(6)模糊,失去鼠标或焦点。(7)MouseMove,鼠标指针在对象上方经过。(8).mouseout,鼠标指针离开对象。2。调用事件调用事件通过事件过程名完成,事件过程名由在与事件名称组合而成,事件过程的具体内容可以是语句、方法或函数。如:onclick、onsubmit、onload等,都是事件过程名。举例(当鼠标指到文字或离开文字时窗口状态栏显示相应信息)鼠标移到这里或离开时请查看状态栏结束

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 社会民生


经营许可证编号:宁ICP备18001539号-1