用JS显示文字的例子: 用HTML标签来格式化文本的例子: 书写JS位置的例子: 打开页面弹出窗口的例子 在BODY区内输出显示文本的例子: 调用其它的一个JS文件的例子:
变量的使用 变量使用的例子: This example declares a variable, assigns a value to it, and then displays the variable. Then the variable is displayed one more time, only this time as a heading. 函数的例子 函数使用的一个例子: By pressing the button, a function will be called. The function will alert a message. 带一个参数的函数的例子: By pressing the button, a function with an argument will be called. The function will alert 不同的两个参数调用函数的例子:
利用函数返回值的例子: The script in the body section calls a function. The function returns a text. 带参数的函数返回值的例子: The script in the body section calls a function with two arguments, 2 and 3. The function returns the sum of these two arguments. 条件语句的例子 简单条件语句的例子:
if ... else 的条件语句的例子:
用随机数产生连接的例子: 多条件的语句实现的例子: This example demonstrates the switch statement. You will receive a different greeting based on what day it is. Note that Sunday=0, Monday=1, Tuesday=2, etc. 循环的例子: for循环的一个例子: Explanation: The for loop sets i equal to 0. As long as i is less than , or equal to, 5, the loop will continue to run. i will increase by 1 each time the loop runs. 复杂循环的一个例子: 按条件循环while的例子: Explanation: i equal to 0. While i is less than , or equal to, 5, the loop will continue to run. i will increase by 1 each time the loop runs. do...while循环的例子: Explanation: i equal to 0. The loop will run i will increase by 1 each time the loop runs. While i is less than , or equal to, 5, the loop will continue to run. 字符串对象的例子: 检测字符串长度的例子: 检测子字符串位置的例子: This example tests if a string contains a specified word. If the word is found it returns the position of the first character of the word in the original string. Note: The first position in the string is 0! 检测子字符串是否存在的例子: This example tests if a string contains a specified word. If the word is found it returns the word. 取子字符串的例子:
转换字符串的大小写 数组对象的实例 数组简单应用的例子: 另一种使用数组的方法: 使用数组的一些属性和方法: 数组的两个方法concat和slice 日期相关例子: 显示今天的日期: 显示当前的时间: 设置日期: UTC时间: 显示当前的星期: 显示当前的日期和星期: 一个走动的时间: 数学对象的例子: 产生0-1之间的随机数的例子 产生0-10的随机数的例子 求最大数的例子: 求最小数的例子: Convert Celsius to Fahrenheit Insert a number in either input field, and the number will be converted into either Celsius or Fahrenheit. Note that the Math.round method is used, so that the result will be returned as a whole number. 转变字符为数字的例子 超级连接对象 用按钮来改变连接位置的例子: Visit Microsoft 改变连接的打开方式的例子: Visit W3Schools Try the link before and after you have pressed the button! 使连接获得焦点和失去焦点 Visit W3Schools.com 连接打开的方式 Links and AnchorsClick on a button to display that anchor in window 2! 按钮对象 创建一个按钮 显示按钮的名称 显示表单中各个项的名称 副选框的选择和取消 表单中的副选框的选择与取消 副选框实现的功能(转换为大写) 文档对象 显示连接的数量 First anchor Second anchor Third anchor Number of anchors in this document: 显示当前所在服务器的地址 The domain name for this site is: 显示当前页面的地址: The referrer of a document is the URL of the document that linked to a document. The referrer of this document is: In this case it is a frame page that is linking to this document. IE returns the URL of the frame page and Netscape returns the URL of the document linking to this document. 显示当前文档的标题 The title of the document is: 用按钮来显示当前页面的地址 通过单击可以知道当前的标签 Click to see what element I am!显示表单中元素的个数 打开一个新的文档,显示几个文字 打开一个新的文档,并显示新的文档 Learning how to access the DOM is....计算表单的个数 计算一个页面中图形的个数 显示表单的名字 You can use the form's number: Or, the form's name (will not work in Netscape): 事件对象 单击弹出窗口 Click in the document. An alert box will alert which mouse button you clicked. 单击弹出窗口显示鼠标的位置 Click in the document. An alert box will alert the x and y coordinates of the cursor. 按一个键则显示该键的ASCII码 Note: Make sure the right frame has focus when trying this example! Press a key on your keyboard. An alert box will alert the unicode of the key pressed. 单击任何地方显示鼠标在页面的坐标
单击之后显示文档的鼠标坐标
显示SHIFT是否被按下
单击显示我们页中的标签 Click somewhere in the document. An alert box will alert the tag name of the element you clicked on. This is a headerThis is a paragraph 显示事件发生的类型
表单对象 用表单显示地址: 显示表单所使用的方法 重置表单 提交表单 对email的验证 Note: This example ONLY tests if the e-mail address contains an "@" character. A "real-life" code 输入指定的数才能提交表单 输入特定长的字符才能提交表单 对表单的检测 设置表单中的一项获得焦点 选择文本框中的文本 下拉列表框的取值 单选按钮的取值 下拉列表的值的显示 下拉列表的连接 光标自动跳到下一个文本区 This script automatically jumps to the next input field when the current field's maxlength has been reached. Frame, Frameset 和 IFrame 对象 平分两个页面 Try to resize the frame. Right-click inside the two frames and select "View Source" to see the source code. 是否显示滚动条 Right-click inside the frames and select "View Source" to see the source code. 改变页面的地址: Right-click inside the two frames and select "View Source" to see the source code. 跳出框架 更新两个页面 Right-click inside the two frames and select "View Source" to see the source code. 更新2个以上的页面 Right-click inside the three frames and select "View Source" to see the source code. 更新两个IFRAME 图象对象 改变图象的高度 改变图象 改变图象的宽度 定位: 显示当前页的地址和改变当前页的地址 刷新页面 导航对象 检测你的浏览器 显示浏览器更加详细的信息 最详细的浏览器的信息 按浏览器不同实现导航 检测浏览器的版本 选择对象 设置下拉列表的可用性 返回下拉列表中选择的项的值 改变下拉列表的大小 列表可选择多项
返回所选列表的文本值 删除列表的项目 显示屏幕的信息 表格对象 改变表格的边框
改变表格的间距
|
|小黑屋|最新主题|手机版|微赢网络技术论坛 ( 苏ICP备08020429号 )
GMT+8, 2024-9-29 17:35 , Processed in 0.191274 second(s), 12 queries , Gzip On, MemCache On.
Powered by Discuz! X3.5
© 2001-2023 Discuz! Team.