騎士の圣殿

 

js速查手册2

js的方法可是有一些,想具体了解,可以去下载一本js手册

a
abs 返回数字的绝对值
acos 返回数的反余弦值
anchor 在对象中的指定文本两端放置一个有 NAME 属性 HTML 锚点
apply 应用某一对象的一个方法,用另一个对象替换当前对象
asin 返回数字的反正弦值
atan 返回数字的反正切值
atan2 返回由 X 轴到 ( y , x ) 点的角度(以弧度为单位)
atEnd 返回一个 Boolean 值,指明枚举算子是否位于集合的末尾
b
big 把 HTML <BIG> 标记放置在 String 对象中的文本两端
blink 把 HTML <BLINK> 标记放置在 String 对象中的文本两端
bold 把 HTML <B> 标记放置在 String 对象中的文本两端
c
call 调用一个对象的一个方法,以另一个对象替换当前对象
ceil 返回大于等于其数字参数的最小整数
charAt 返回指定索引位置处的字符
charCodeAt 返回一个整数,代表指定位置上字符的 Unicode 编码
compile 把正则表达式编译为内部格式,从而执行得更快
concat 返回一个新数组,这个新数组是由两个或更多数组组合而成的
concat(String) 返回字符串值,该值包含了两个或更多个提供的字符串的连接
cos 返回数的余弦值
d
decodeURI 返回一个已编码的统一资源标识符 (URI) 的非编码形式
decodeURIComponent 返回统一资源标识符 (URI) 的一个已编码组件的非编码形式
dimensions 返回 VBArray 的维数
e
encodeURI 将文本字符串编码为一个有效的统一资源标识符 (URI)
encodeURIComponent 将文本字符串编码为一个统一资源标识符 (URI) 的一个有效组件
escape 对 String 对象编码以便它们能在所有计算机上可读
eval 检查 JScript 代码并执行
exec 用正则表达式模式在字符串中运行查找,并返回包含该查找结果的一个数组
exp 返回 e(自然对数的底)的幂
f
fixed 把HTML<TT>标记放置在 String 对象中的文本两端
floor 返回小于等于其数值参数的最大整数
fontcolor 把带有 COLOR 属性的一个 HTML <FONT> 标记放置在 String 对象中的文本两端
fontsize 把一个带有 SIZE 属性的 HTML <FONT> 标记放置在 String 对象中的文本的两端
fromCharCode 从一些 Unicode 字符值中返回一个字符串
g
getDate 返回 Date 对象中用本地时间表示的一个月中的日期值
getDay 返回 Date 对象中用本地时间表示的一周中的日期值
getFullYear 返回 Date 对象中用本地时间表示的年份值
getHours 返回 Date 对象中用本地时间表示的小时值
getItem 返回指定位置的项
getMilliseconds 返回 Date 对象中用本地时间表示的毫秒值
getMinutes 返回 Date 对象中用本地时间表示的分钟值
getMonth 返回 Date 对象中用本地时间表示的月份值
getSeconds 返回 Date 对象中用本地时间表示的秒钟值
getTime 返回 Date 对象中的时间值
getTimezoneOffset 返回用分钟表示的主计算机上的时间和全球标准时间 (UTC)之间的差别
getUTCDate 返回 Date 对象中用全球标准时间 (UTC)表示的日期
getUTCDay 返回 Date 对象中用全球标准时间 (UTC)表示的一周中的日期值
getUTCFullYear 返回 Date 对象中用全球标准时间 (UTC)表示的年份值
getUTCHours 返回 Date 对象中用全球标准时间 (UTC)表示的小时值
getUTCMilliseconds 返回 Date 对象中用全球标准时间 (UTC)表示的毫秒值
getUTCMinutes 返回 Date 对象中用全球标准时间 (UTC)表示的分钟值
getUTCMonth 返回 Date 对象中用全球标准时间 (UTC)表示的月份值
getUTCSeconds 返回 Date 对象中用全球标准时间 (UTC)表示的秒钟值
getVarDate 返回 Date 对象中的 VT_DATE 值
getYear 返回 Date 对象中的年份值
i
indexOf 返回 String 对象内第一次出现子字符串的字符位置
isFinite 返回一个 Boolean 值,指明所提供的数字是否是有限的
isNaN 返回一个 Boolean 值,指明提供的值是否是保留值 NaN (不是数字)
italics 把 HTML <I> 标记放置在 String 对象中的文本两端
item 返回集合中的当前项
j
join 返回字符串值,其中包含了连接到一起的数组的所有元素,元素由指定的分隔符分隔开
l
lastIndexOf 返回 String 对象中子字符串最后出现的位置
lbound 返回在 VBArray 的指定维中所使用的最小索引值
link 把一个有 HREF 属性的 HTML 锚点放置在 String 对象中的文本两端
localeCompare 返回一个值,指出在当前的区域设置中两个字符串是否相同
log 返回数字的自然对数
match 使用正则表达式模式对字符串执行查找,并将包含查找的结果作为数组返回
max 返回给出的零个或多个数值表达式中较大者
min 返回给出的零个或多个数值表达式中较小者
moveFirst 重新将集合中的当前项设置为第一项
moveNext 将集合中的当前项移动到下一项
p
parse 解析一个包含日期的字符串,并返回该日期与 1970 年 1 月 1 日午夜之间所间隔的毫秒数
parseFloat 返回由字符串转换得到的浮点数
parseInt 返回由字符串转换得到的整数
pop 移除数组中的最后一个元素并返回该元素
push 将新元素添加到一个数组中,并返回数组的新长度值
r
random 返回介于 0 和 1 之间的伪随机数
replace 返回根据正则表达式进行文字替换后的字符串 的拷贝
reverse 返回一个元素顺序被反转的 Array 对象
round 返回与给出的数值表达式最接近的整数
s
search 返回与正则表达式查找内容匹配的第一个子字符串的位置
setDate 设置 Date 对象中用本地时间表示的数字日期
setFullYear 设置 Date 对象中用本地时间表示的年份值
setHours 设置 Date 对象中用本地时间表示的小时值
setMilliseconds 设置 Date 对象中用本地时间表示的毫秒值
setMinutes 设置 Date 对象中用 本地时间表示的分钟值
setMonth 设置 Date 对象中用 本地时间表示的月份值
setSeconds 设置 Date 对象中用 本地时间表示的秒钟值
setTime 设置 Date 对象的日期和时间值
setUTCDate 设置 Date 对象中用全球标准时间 (UTC)表示的数值日期
setUTCFullYear 设置 Date 对象中用全球标准时间 (UTC)表示的年份值
setUTCHours 设置 Date 对象中用全球标准时间 (UTC)表示的小时值
setUTCMilliseconds 设置 Date 对象中用全球标准时间 (UTC)表示的毫秒值
setUTCMinutes 设置 Date 对象中用全球标准时间 (UTC)表示的分钟值
setUTCMonth 设置 Date 对象中用 全球标准时间 (UTC)表示的月份值
setUTCSeconds 设置 Date 对象中用全球标准时间 (UTC)表示的秒值
setYear 设置 Date 对象中的年份值
shift 移除数组中的第一个元素并返回该元素
sin 返回数字的正弦值
slice (Array) 返回一个数组的一段
slice (String) 返回字符串的片段
small 将 HTML 的<SMALL> 标识添加到 String 对象中的文本两端
sort 返回一个元素已经进行了排序的 Array 对象
splice 从一个数组中移除一个或多个元素,如果必要,在所移除元素的位置上插入新元素,返回所移除的元素
split 将一个字符串分割为子字符串,然后将结果作为字符串数组返回
sqrt 返回数字的平方根
strike 将 HTML 的<STRIKE> 标识放置到 String 对象中的文本两端
sub 将 HTML 的 <SUB> 标识放置到 String 对象中的文本两端
substr 返回一个从指定位置开始的指定长度的子字符串
substring 返回位于 String 对象中指定位置的子字符串
sup 将 HTML 的<sup> 标识放置到 String 对象中的文本两端
t
tan 返回数字的正切值
test 返回一个 Boolean 值,它指出在被查找的字符串中是否存在模式
toArray 返回一个由 VBArray 转换而来的标准 JScript 数组
toDateString 以字符串值的形式返回一个日期
toExponential 返回一个字符串,其中包含一个以指数记数法表示的数字
toFixed 返回一个字符串,代表一个以定点表示法表示的数字
toGMTString 返回一个日期,该日期用格林威治标准时间 (GMT) 表示并已被转换为字符串
toLocaleDateString 以字符串的形式返回与宿主环境的当前区域设置相对应的日期
toLocaleLowerCase 返回一个字符串,其中所有的字母字符都被转换为小写,同时考虑到宿主环境的当前区域设置
toLocaleString 返回一个日期,该日期使用当前区域设置并已被转换为字符串
toLocaleTimeString 以字符串的形式返回与宿主环境的当前区域设置相对应的时间
toLocaleUpperCase 返回一个字符串,其中所有的字母字符都被转换为大写,同时适应宿主环境的当前区域设置
toLowerCase 返回一个字符串,该字符串中的字母被转换为小写字母
toPrecision 返回一个字符串,其中包含一个以指数记数法或定点记数法表示的,具有指定数字位数的数字
toString 返回对象的字符串表示
toTimeString 以字符串形式返回时间
toUpperCase 返回一个字符串,该字符串中的所有字母都被转化为大写字母
toUTCString 返回一个已被转换为字符串的,用全球标准时间 (UTC)表示的日期
ubound 返回在 VBArray 的指定维中所使用的最大索引值
unescape 解码用 escape 方法进行了编码的 String 对象
unshift 将指定的元素插入数组开始位置并返回该数组
UTC 返回全球标准时间 (UTC) (或 GMT) 的 1970 年 1 月 1 日到所指定日期之间所间隔的毫秒数
valueOf 返回指定对象的原始值

1 创建脚本块

1: <script language=”JavaScript”>
2: JavaScript code goes here
3: </script>

2 隐藏脚本代码
1: <script language=”JavaScript”>
2: <!--
3: document.write(“Hello”);
4: // -->
5: </script>


在不支持JavaScript的浏览器中将不执行相关代码

3 浏览器不支持的时候显示
1: <noscript>
2: Hello to the non-JavaScript browser.
3: </noscript>


4 链接外部脚本文件
1: <script language=”JavaScript” src="http://img.sxsky.net/it//”filename.js"”></script>

5 注释脚本
1: // This is a comment
2: document.write(“Hello”); // This is a comment
3: /*
4: All of this
5: is a comment
6: */

6 输出到浏览器
1: document.write(“<strong>Hello</strong>”);

7 定义变量
1: var myVariable = “some value”;

8 字符串相加
1: var myString = “String1” + “String2”;

9 字符串搜索
1: <script language=”JavaScript”>
2: <!--
3: var myVariable = “Hello there”;
4: var therePlace = myVariable.search(“there”);
5: document.write(therePlace);
6: // -->
7: </script>

10 字符串替换
1: thisVar.replace(“Monday”,”Friday”);

11 格式化字串
1: <script language=”JavaScript”>
2: <!--
3: var myVariable = “Hello there”;
4: document.write(myVariable.big() + “<br>”);
5: document.write(myVariable.blink() + “<br>”);
6: document.write(myVariable.bold() + “<br>”);
7: document.write(myVariable.fixed() + “<br>”);
8: document.write(myVariable.fontcolor(“red”) + “<br>”);
9: document.write(myVariable.fontsize(“18pt”) + “<br>”);
10: document.write(myVariable.italics() + “<br>”);
11: document.write(myVariable.small() + “<br>”);
12: document.write(myVariable.strike() + “<br>”);
13: document.write(myVariable.sub() + “<br>”);
14: document.write(myVariable.sup() + “<br>”);
15: document.write(myVariable.toLowerCase() + “<br>”);
16: document.write(myVariable.toUpperCase() + “<br>”);
17:
18: var firstString = “My String”;
19: var finalString = firstString.bold().toLowerCase().fontcolor(“red”);
20: // -->
21: </script>

12 创建数组
1: <script language=”JavaScript”>
2: <!--
3: var myArray = new Array(5);
4: myArray[0] = “First Entry”;
5: myArray[1] = “Second Entry”;
6: myArray[2] = “Third Entry”;
7: myArray[3] = “Fourth Entry”;
8: myArray[4] = “Fifth Entry”;
9: var anotherArray = new Array(“First Entry”,”Second Entry”,”Third Entry”,”Fourth Entry”,”Fifth Entry”);
10: // -->
11: </script>

13 数组排序
1: <script language=”JavaScript”>
2: <!--
3: var myArray = new Array(5);
4: myArray[0] = “z”;
5: myArray[1] = “c”;
6: myArray[2] = “d”;
7: myArray[3] = “a”;
8: myArray[4] = “q”;
9: document.write(myArray.sort());
10: // -->
11: </script>

14 分割字符串

1: <script language=”JavaScript”>
2: <!--
3: var myVariable = “a,b,c,d”;
4: var stringArray = myVariable.split(“,”);
5: document.write(stringArray[0]);
6: document.write(stringArray[1]);
7: document.write(stringArray[2]);
8: document.write(stringArray[3]);
9: // -->
10: </script>

15 弹出警告信息
1: <script language=”JavaScript”>
2: <!--
3: window.alert(“Hello”);
4: // -->
5: </script>

16 弹出确认框
1: <script language=”JavaScript”>
2: <!--
3: var result = window.confirm(“Click OK to continue”);
4: // -->
5: </script>

17 定义函数
1: <script language=”JavaScript”>
2: <!--
3: function multiple(number1,number2) {
4: var result = number1 * number2;
5: return result;
6: }
7: // -->
8: </script>

18 调用JS函数
1: <a href=”#” onClick=”functionName()”>Link text</a>
2: <a href="/”javascript:functionName"()”>Link text</a>

19 在页面加载完成后执行函数
1: <body onLoad=”functionName();”>
2: Body of the page
3: </body>


20 条件判断
1: <script>
2: <!--
3: var userChoice = window.confirm(“Choose OK or Cancel”);
4: var result = (userChoice == true) ? “OK” : “Cancel”;
5: document.write(result);
6: // -->
7: </script>

21 指定次数循环
1: <script>
2: <!--
3: var myArray = new Array(3);
4: myArray[0] = “Item 0”;
5: myArray[1] = “Item 1”;
6: myArray[2] = “Item 2”;
7: for (i = 0; i < myArray.length; i++) {
8: document.write(myArray[i] + “<br>”);
9: }
10: // -->
11: </script>

22 设定将来执行
1: <script>
2: <!--
3: function hello() {
4: window.alert(“Hello”);
5: }
6: window.setTimeout(“hello()”,5000);
7: // -->
8: </script>

23 定时执行函数
1: <script>
2: <!--
3: function hello() {
4: window.alert(“Hello”);
5: window.setTimeout(“hello()”,5000);
6: }
7: window.setTimeout(“hello()”,5000);
8: // -->
9: </script>

24 取消定时执行
1: <script>
2: <!--
3: function hello() {
4: window.alert(“Hello”);
5: }
6: var myTimeout = window.setTimeout(“hello()”,5000);
7: window.clearTimeout(myTimeout);
8: // -->
9: </script>

25 在页面卸载时候执行函数
1: <body onUnload=”functionName();”>
2: Body of the page
3: </body>

posted on 2007-11-19 11:34 最後の騎士 阅读(432) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航:
 

导航

统计

常用链接

留言簿(1)

随笔分类

随笔档案

文章分类

搜索

最新评论

阅读排行榜

评论排行榜