函数是可再用的代码块,可以在事件触发或是被调用时来执行。 JS函数 要想让浏览器在加载完页面后马上执行脚本程序,你可以将脚本写入一个函数内。 函数内的一些代码只有在某个事件触发或被调用的时候才会被执行。 你可以在页面中的任何地方调用函数(可以用嵌入外部.js文件的方式让其他页面也可以使用脚本) 函数在页面的开始

Posted at 08-06-05 by 佚名 views(18)

在JS中的循环用来重复执行指定次数的代码或当条件为真时重复执行。 JS 循环 当你写代码的时候会经常要让一段代码一行行的重复执行,要完成这样的任务不需要你添加重复的代码,我们只要使用循环就行。 在JS中有两种循环: for - 次数循环 while - 条件循环 for循环 使用for循环一般是当你事先知道脚本应该执行几次。 语法

Posted at 08-06-05 by 佚名 views(16)

在JS里循环通常是要某段代码执行一个指定的次数或是在某一特殊条件下执行。 while循环 当条件持续为真的时候循环执行相同的代码, 这就是while循环的用途 while (var=endvalue) { code to be executed } 注意:=可以比较任何申明(我的理解是不光可以比较数字类型,字符也可以比较) 例子 解释:下面的例子

Posted at 08-06-05 by 佚名 views(15)

for...in声明通过一组元素或对象属性进行循环(重复) JS的for...in声明 在for...in循环躯干部分里的代码针对每个元素/属性执行一次 语法 for (variable in object) { code to be executed } 变量可以是数组或是对象的属性 举例 数组使用for...in循环 htmlbody script type=text/javascrip

Posted at 08-06-05 by 佚名 views(15)

Events are actions that can be detected by JavaScript. JS可以察觉到事件有动作 (此处原文翻译有误,应该是事件是指javascript可以观察到的动作下面的也犯有同样毛病,就不一一改正了。) 事件 通过使用JS我们能够建立动态的web页面.JS能够察觉到事件有动作 web页中的每个元素都能够有触发JS函数的事件。举例来说,我们

Posted at 08-06-05 by 佚名 views(16)

The try...catch statement allows you to test a block of code for errors. 使用try...catch声明让你能够测试出错误的代码 JavaScript - Catching Errors JS-捕捉错误 When browsing Web pages on the internet, we all have seen a JavaScript alert box telling us there is a runtime e

Posted at 08-06-05 by 佚名 views(13)

The throw statement allows you to create an exception. throw声明可以让你建立例外(情况) The Throw Statement The throw statement allows you to create an exception. If you use this statement together with the try...catch statement, you can control program flow and

Posted at 08-06-05 by 佚名 views(10)

Using the onerror event is the old standard solution to catch errors in a web page. 使用onerror事件是捕捉web页错误的比较老的标准方法。 The onerror Event We have just explained how to use the try...catch statement to catch errors in a web page. Now we are going to explai

Posted at 08-06-05 by 佚名 views(14)
Copyright ?2005-2008 All rights reserved. www.17zixue8.com 版权所有    赣ICP备07501614号        完美兵团会员待遇说明    站主QQ:335759285