Академический Документы
Профессиональный Документы
Культура Документы
2-
,
:
JavaScript
-
()
()
JavaScript
2-
-
--
2005
32.988.02-0187
004.738.5(075)
83
.
83 JavaScript, 2- . .: , 2005. 395 .: .
ISBN 5-469-00804-5
JavaScript. ,
. -,
, Windows Scripting Host.
JavaScript HTML. , ,
- .
.
32.988.02-0187
004.738.5(075)
.
.
, , , .
, ,
, .
ISBN 5-469-00804-5
, 2005
13
1. JavaScript
18
2.
3.
169
4.
180
5. Windows
277
1. HTML
297
2. HTML
362
385
11
12
13
1. JavaScript
18
1.1.
1.2.
1.2.1. alert
1.2.2. confirm
1.2.3. prompt
1.3.
1.4.
1.4.1.
1.4.2.
1.4.3.
1.5.
1.5.1.
1.5.2.
1.5.3.
1.5.4.
1.5.5.
1.5.6.
1.5.7.
1.5.8.
1.6.
1.6.1.
1.6.2.
1.6.3.
1.7.
1.7.1. String ()
1.7.2. Array ()
1.7.3. Number ()
1.7.4. Math ()
1.7.5. Date ()
18
22
22
23
24
25
29
30
30
31
32
32
33
35
35
37
38
42
46
48
48
50
55
55
57
66
74
79
85
1.7.6. Boolean ()
1.7.7. Function ()
1.7.8. Object
1.8.
1.8.1.
1.8.2.
1.8.3.
1.8.4.
1.9.
1.9.1.
1.9.2.
1.9.3.
1.10.
1.11.
91
91
95
96
97
98
99
99
103
103
104
105
106
108
2.
110
2.1.
2.2. HTML
2.2.1. HTML
2.2.2. HTML
2.3. ,
2.3.1.
2.3.2.
2.3.3. ,
2.4.
2.4.1.
2.4.2.
2.4.3.
2.5.
2.5.1.
2.5.2.
2.5.3.
2.5.4.
2.6.
2.6.1. writeQ
2.6.2.
2.6.3.
2.7.
2.8.
2.9. Cookie
113
116
117
117
120
124
131
131
137
139
140
141
144
150
151
154
155
155
156
158
161
163
3.
3.1. window
3.1.1. window
3.1.2. window
3.1.3. window
169
169
169
171
171
'
8
3.2. document
3.2.1. document
3.2.2. document
3.2.3. document
3.2.4. document
3.3. location
3.3.1. location
3.3.2. location
3.4. history
3.4.1. history
3.4.2. history
3.5. navigator
3.5.1. navigator
3.5.2. navigator
3.5.3. navigator . . . *
3.6. event
3.7. screen
3.7.1. TextRange
3.7.2. TextRange
3.7.3. TextRange
4.
4.1.
4.1.1.
4.1.2.
4.1.3.
4.1.4.
4.1.5.
4.1.6.
4.1.7.
4.2.
4.2.1.
4.2.2.
4.3.
4.3.1.
4.3.2.
4.3.3. ,
4.3.4. ,
4.3.5.
4.4.
4.5.
4.6.
4.6.1.
4.6.2.
4.7.
4.8.
4.8.1.
172
172
173
173
174
175
175
175
175
176
176
176
176
176
177
177
178
178
178
178
180
180
180
182
183
184
185
188
195
196
196
203
211
212
217
220
221
223
225
229
234
234
236
241
244
244
4.8.2.
4.8.3.
4.8.4.
4.8.5.
4.8.6.
4.8.7.
4.8.8. HTML-
4.8.9.
4.8.10. -
4.9. Flash-
4.9.1. JavaScript ActionScript
4.9.2. JavaScript ActionScript
5.
Windows
5.1.
5.2.
5.3.
5.3.1.
5.3.2. ,
5.4.
,
5.4.1.
5.4.2. ,
5.4.3.
5.4.4.
5.4.5.
5.5.
1. HTML
246
247
248
255
256
258
263
265
267
271
272
275
277
278
279
282
282
283
284
284
286
287
290
292
292
297
297
303
304
305
309
310
310
312
313
314
316
317
319
320
320
320
10
URL-
Flash- -
(radiobuttons)
<>
HTTP-EQUIV (HTTP-)
NAME ()
322
323
325
333
337
340
343
347
347
348
350
351
353
354
355
359
359
360
2. HTML
362
HTML
, ,
HTML
HTML
362
362
362
363
363
364
364
365
365
365
366
366
366
367
383
385
web- (2001) web (2002) ,
JavaScript . , .
, . , , HTML, -
, . , , . , - HTML, ,
. HTML, JavaScript
. ,
. ,
.
JavaScript ,
1000 . , ,
, , . , JavaScript,
.
, . ,
, - .
. , JavaScript,
. , JavaScript C++, Java . , , .
JavaScript, .
- JavaScript ,
, . ,
. - , ,
12
. ,
, JavaScript .
JavaScript. .
,
www.admiral.ru/~dunaev. . ,
. !
, , comp@piter.com ( , ).
!
- http://www.piter.com .
, (, ),
, .
, , , , .
, , , .
, . , . ; ,
... . .
, . , ,
, .
, ,
, ,
. ! , , . , . , ,
, ,
. , , , -
. ,
.
, - , . . ,
, . ,
, ,
, . ()
, -
14
. ,
, , . , . , , - , .
, ,
.
,
JavaScript, . ,
(Notepad) Windows (. B.I), :
WScript.echo("!")
5 p.oba.js-
klScript.echo("npMBeT?");
_J
,:
. B.I.
JavaScript,
. , , proba.js.
, js , , JavaScript. , * . (*.*),
js, proba.js (. .2).
.
l -I !
;
................ .........
^1
|p editot.htm
, htm
JavaCKpHnr.doc
. .2.
15
. .. ,
.
:
<html>
<script>
alert("")
</script>
</html>
proba.htm. ,
-, ! (. .4).
&-
16
, : .
,
, . , .
Windows, Windows Scripting Host,
-. , JavaScript,
, , , . .
, ,
() .
- , - . . , . ,
. ,
, , .
. , -, , . , . , JavaScript, Microsoft Internet
Explorer Netscape, .
, , .
, , . , .
,
. , .
1.5 JavaScript.
Microsoft Internet Explorer 6.0 Windows;
Internet Explorer 4+ Windows, , , Internet Explorer 5 Macintosh.
Netscape Navigator 4 . , , Internet Explorer Windows,
. , Internet Explorer 4 Windows , .
Internet Explorer Windows 5.5 , ,
, . -
JavaScript, -
. - , , .
17
1 JavaScript. 2 , , . ,
. 3. .
. ,
, 4. ,
JavaScript -. 5 Windows
JavaScript. ,
. HTML.
. ,
, , ,
-
. - ,
. . , .
1. JavaScript
1.1.
JavaScript: ( ). . -,
: ( ) JavaScript -. Internet Explorer 6.0. 5.0 .
- , Windows. , ,
.
:
<1_>
<><11></1/>
<SCRIPT>
</SCRIPT>
</HTML>
, HTML-, -. , .htm.
htm html, , . HTML.
JavaScript <SCRIPT> </SCRIPT>.
JavaScript. Enter, . :
<HTML>
<><11></TITLE></HEAD>
<SCRIPT>
= 5
= + 3
alert(y)
</SCRIPT>
</HTML>
1.1.
19
. alertQ,
, .
alert(y) ,
( 8).
alert(y), .
,
-, alert(y) :
document.writeln()
( .htm) - ,
Windows.
, -
HTML >
HTML. (. 1.1). ( >
). - , > (. 1.2). , , .
. him -
<HTML>
^ -x\1 1
1
TI
.1/
TT
I t
PSi'/IIPuri
HU
Lt
x l 1\// 1T1
IL
xx/ntHU
<SCRIPT>
X = 5
= X + 3
alert(y)
</SCRIPT>
</HTML>
'[>--*.-
:
I
fli
I
LSI KOI,
JavaScript ,
-, Microsoft FrontPage
Macromedia Dreamweaver (. 1.3).
.
20
1. JavaScript
- Microsoft Estpiors
. 1.2. .htm
( JavaScript/ htw")
9
:1>
|<11><11/>
j<SCRIPT>
htm :::
5
falertM
/SCRIPT>
(</HTML>
!<HTML>
|1<><!1>/-></>
<SCRIPT>
:By - X + 3
lfalert(y)
I
</SCRIPT>
I </HTML>
$* I
j~*
'
||1^! |
<~frl^j
i-. 1 - ' -
, .
HTML-
21
1.1.
.htm .html.
-. :
<HTML>
<> JavaScript</H3>
:<>
<TEXTAREA id="mycode" ROWS=10 COLS=60></TEXTAREA>
<>:<>
b</BUTTON>
BUTTON onclick="document.all.mycode.value='';
document.all.myrezult.value=''">
04HCTHTb</BUTTON>
<P>
<! >
.
.
.
, Enter.
</HTML>
3 - Microsoft Internet Explore!
Cgpac
'
fr : 1
^!1
JavaScript
:
= 2+3
= + 5
:
10
. .
.
, Enter.
22
1. JavaScript
- HTML- :
JavaScript,
. : , . ,
. ,
JavaScript, HTML.
, .
, JavaScript, , (onclick).
. 1.4 , Internet Explorer.
,
( -) > .
1.2.
JavaScript . , JavaScript
-. - , HTML, .
JavaScript HTML-,
HTML JavaScript,
- Internet Explorer, : alertQ,
promptQ confirmQ. .
1.2.1. alert
. :
1(")
1.2.
23
Microsoft Internet Explorer
, 1() .
- , .
1.2.2. confirm
confirm (Cancel). alert , , . , true
(, ); , false
(, ). , , ,
. confirm :
confi()
, , , . , confirm("Bbi ?") (. 1.6).
, : , , ( ),
. , , .
Microsoft Internet Exploiei
. 1.6. , confirm
, confirm(),
. ,
. , , . , , confirmQ,
1. JavaScript
24
. , true (, ), , false (, ).
, , , .
1.2.3. prompt
prompt ,
, (. 1.7). , : (Cancel).
alertQ confirm() : , .
, ,
, false (,
). , ,
,
. prompt :
p r o m p t ( , ___)
1
. . *;", :: -'.-
* Ornail
1
i
, ||
!|jmumu(igeiasim.tij
. 1.7. , prompt
prompt() . ,
, undefined ( ). ,
, "". , prompt(" ,
", "")(. 1.8).
. 1.8. , promptQ
, promptQ,
.
confirmQ, .
25
1.3.
1.3.
.
,
.
, ,
. (. 1.1.)
, , .
, . , , .
. ,
5? , : . ,
, ,
. , , . , ,
+, , , .
, ,
. . , , ,
. , , +, :
, (, ).
1.1. JavaScript
(string)
(number)
""
".. 123-4567"
3.14 -567 +2.5
(, boolean)
Null
(object)
true false
,
,
, ,
(+ -);
+;
.
true (, ) false (, );
,
. ,
(function)
26
1. JavaScript
() .
. ,
, . , " '. , -345.12
, "-345.12" . , ,
. , ,
, () .
(, ) , .
? , , .
, , ; , (, , . .).
, . ,
, .
, "", ( ), . , (," "),
.
: true false.
. true (), a false (). , (, , ). , 2 < 3 , , true (, 2 3).
(boolean)
, .
(Null, Object Function) , .
JavaScript .
, , , .
, . , Pascal, , .
, 5+"", "5". , ,
, , , . JavaScript , .
1.3.
27
parselnt("3.14")
parselnt("-7.87S")
parselnt("435")
parselnt("")
p a r s e l n t ( " 1 5 " ,8)
parse!nt("0xFF",16)
//
//
//
//
//
//
= 3
= -7
= 435
= NaN,
= 13
= 255
, : .
parseFloat(cipoKa)
(, ) .
parseFloat("3.14")
parseFloat("-7.875")
parseFloat ( " 4 3 5 " )
parseFloat ( " " )
parseFloat ("17.5")
//
//
//
//
//
=
=
=
=
=
3.14
-7.875
435
NaN,
435
, . , , +. ,
""+3.14 "3.14".
.
, , 1$(). . ,
true, false. . i s N a N Q
28
1. JavaScript
, , . . true 1, false
0. , isNaN false, , , ,
, (true false).
isNaN(123)
isNaN( "123")
i s N a N ( " 5 0 ")
isNaN(true)
isNaN(false)
1("")
// false ( - )
/* false ( - ,
) */
// true ( - )
/ / false
/ / false
// true ( - )
,
.
\t
\f
. , , , Internet Explorer alert(),
, \ (. 1.9):
!" - - - ")
Microsoft Inletnel Exptoret
-
. 1.9. , alertQ,
\
, . , , , ? \ ( ). ,
" " , : " \" \"".
,
. , -
1.4.
29
, . Internet Explorer
1:(" \" \"") , . 1.10.
Microsoft Internet Explorer
" "
, ,
( ). -, : ' " "'. . -, : " ' '".
. , , : " " "".
.
.
, ,
.
, ,
, .
, ,
( , ).
1.4.
, - , 314? , - . .
, .
30
1. JavaScript
1.4.1.
. , , . ,
, .
: myFamily, my_adress, _x, tel412_3456.
: 512group, my adress, tel:412 3456.
, , . , var, if, else, const, true, false, function, super, switch .
1.11. . , , . : my_first_adress, myFirstAdress.
, () : (character), n (number), b (boolean),
(object), a (array). cAdress, nCena, aMonth.
JavaScript . , ( ) . : variable, Variable vaRiabLe
.
, . , .
1.4.2.
:
:
_ =
=.
:
myName = ""
var ( variable ) :
var _
,
.
:
var myName
myName = ""
1.4.
31
var :
var _ =
var ' . , .
, . . , :
var x = ""
//
= ""
//
= 2.5
var , , . , :
var name = "", address, x = 3.14
, ,
. , (), ( null) .
, =. . =
: , .
, = : . ,
, = .
,
. , , . 1.5.3 , +=, -= . .
1.4.3.
,
var , .
, ,
. . .
. . -
32
1. JavaScript
, . ,
var, :
, .
.
.
, .
.
(, ).
, . .
JavaScript
. , () HTML- -,
.
1.5.
.
, . , , . ,
, , ,
. , .
, , 2 3, 5. , .
, .
. =. . , , = , , ,
.
1.5.3.
1.5.1.
. , ,
.
JavaScript :
// , , ;
/*...*/ , /* */, ;
.
1.5.
33
. . , ( ?).
,
, , .
.
1.5.2.
, , . ., JavaScript
. , . (. 1,2).
1.2.
X+Y
X-Y
X* Y
/
%
X/Y
X%Y
++
++
Y-
. .
. , 8%3 2. ++ - , . ++
+1, X -1.
++ -- .
- ( )
, ( ) , .
= 5
= + 3
++
-++
5-3
-3
//
//
//
//
//
//
//
5
8 (5+3)
9 (8+1)
8 (9-1)
6 (5+1)
. -
34
1. JavaScript
, . ,
"" + "" "".
. N a N , ( . 1.7.3. ,
,
.
z
z
=
=
=
=
=
""
""
+ " " +
+ 5
"20" + 5
//
//
//
//
/*
30 " 3 0 " */
z
z
" "
""
" "
" 5 "
" 2 0 5 " ,
true + true
true + false
true * true
true/false
true + 5
false + 5
true * 5
true / 5
// 2
// 1
// 1
/* Infinity (,
) */
/ / 6
/ / 5
// 5
/ / 0.2
, ,
, .
"" + true
// "Bacfltrue"
"5" + true
// "Strue"
"" " true
/* NaN ( ,
) */
' true
// 5
"5" * false
// 0
"5" / true
// 5
, . , , :
;
(, );
1.5.
35
true false 1 ,
.
, JavaScript , . , .
1.5.3.
, = , .
+=
X+-Y
X=X+Y
X-=Y
X=X-Y
X * Y
XX * Y
/-
X/=Y
X=X/Y
%=
X%=Y
X=X%Y
, .
, .
:
= ""
1.5.4.
, - .
, - , Microsoft Internet Explorer Netscape Navigator. .
,
, , . . , ( ), , true false. , (, ), true. false.
X = =Y
XI-Y
36
1. JavaScript
>
<=
X*Y
( )
X >= Y
X<Y
( )
<= Y
= .
, . , ASCII- . ,
1 0 (true 1, a false 0). , . .
"abcd"=="abc"
"abc"=="abcd"
"abcd"=="abcd"
" a b c d " = = " abed"
//
//
//
/*
//
//
//
//
false
false
true
false (1-
2 - - ) */
true
true
true
true
ASCII . ,
ASCII- : , 0 9,
, (
, ).
, . ,
.
. , . .
( ), ,
. ("") 0. , !=, false ( != , true).
1.5.
true
true
true
true
==
!=
<=
>=
37
//
//
//
//
"true"
"true"
"true"
"true"
false
true
false
false
1.5.5.
, ,
, . ()
, . , :
30 10, .
, . true false.
()
&&
X&&Y
||
X||Y
! ,
: X true, ! false,
, X false, ! true.
, .
Y
X && Y
X 11 Y
true
true
true
true
true
false
false
true
false
true
false
true
false
false
false
false
, .
38
1. JavaScript
z
z
=
=
=
=
=
false || 2*2==4
5<2 || " a b e d " < = " x y "
!
&&
||
//
//
//
//
//
z
z
true
true
false
false
true
, , ,
. ,
, ,
. , && ;
false, ,
, false. 11 true, , ,
true.
. , - , , .
1.5.6.
, . if switch.
if
if ..., ..., ...
if :
if
()
{ , , }
else
{ , , }
. , . , else (), . ,
if ():
if
()
{ , , }
. , , true false.
.
1. age ().
1.5.
39
if
(age<18)
{alertC'Bbi " ) }
else
{alert (" " ) }
2. ,
18.
if (age<18)
{alertC'Bbi " ) }
, . , . , :
if () {
. ,
} else {
, ,
}
,
.
if:
if (!) {
, , !
} else { if (2){
, , 2
}else{
, , 2
, if
. , .
, . , ""
, (, ,
). ,
, . .
, , ,
, - .
, ( 0, ""
null). , :
if (!)
{
alertC'Bbi ")
}
, , , :
if ( ! x ) alertC'Bbi ")
40
1. JavaScript
switch
if. switch ().
, ,
.
switch :
switch () {
case !:
[break]
case 2:
[break]
[default:
]
}
, = 2
switsch (x) {
case 1:
alert(l)
case 2:
alert(2)
case 3:
alert(3)
}
2- 3- . ,
- ( ,
), break.
1.5.
41
= 2
switsch (x) {
case 1:
alert(l) ;
break
case 2:
alert(2) ;
break
case 3:
alert(3) ;
break
}
2- .
, xlang , . switch:
switsch (xlang) {
case "" :
wi ndow. open ("engl .htm") ;
break
case "":
wi ndow. open ("french. htm") ;
break
case "" :
w i ndow. open ("german. htm") ;
break
default:
alert("y ")
}
window.openQ
HTML-. ,
if:
if (xlang == "")
window. open ("engl. htm")
else {
if (xlang == "")
wi ndow. open ("french. htm") ;
else {
if (xlang == "")
window. open ("german. htm")
/
else
alertC'V ");
:
if (xlang == "") window. open("engl . htm" )
else { if (xlang == "") window. open ("french . htm")
else { if (xlang == "") wi ndow. open ( "german . htm")
else a l e r t C ' Y ")
}
I
42
1. JavaScript
1.5.7.
, . JavaScript
: for, while do-while. ,
, for while. , , while. ,
, .
for
for () ,
. :
for ( [ ] ; [] ; [ ] )
{
, . ,
:
for ( [ ] ; [] ; [ ] ) {
}
, for,
, .
.
. if. ,
, .
.
. . ,
( ). , for, . ( for). , , ,
. ,
.
. , i = 0 var i = 0. . . , , , ,
i<=nMax. , i = i + 1 , , i++.
, 15 :
1.5.
43
, 1 15:
v a rs = l
for (i = 1; i <= 15; i++) {
s = s + i
}
, , .
, , ,
. : *** ... ,
. ,
10, :
. , ? , :
/* */
var z =
// z
for (i = 2 ; i <= ; i++) {
z=z*x
}
z.
. 1, ,
2 <= 1 (
), , , : 1 .
2, , z = z*x z, ( z = *). , 3,
. , z = z*x
z, *, , , ** ( 3).
.
!. , 0 1, ! 1. ! 2*3*4* ... *.
, . , , :
/* !
var z = 1
if (n >1) {
*/
/I !
for (1 = 2 : 1 <=
z=z*i
( ) break (). , .
44
1. JavaScript
break , ,
.
break :
for ( [ ] ; [!] ; [ ] )
i f (2){
break
continue (). , break,
. , break, continue ,
, , .
break :
f o r ( [ ] ; [!] ; [ ] )
if (2){
continue
}
}
while
while ( , ) , for, . :
while ( )
{
, , while.
, , . .
( )
, , . .
while for, , , . , ( ).
,
for.
45
1.5.
.
/*
var z =
i = 2
while (i = 2) {
// z
Z = Z*X
!.
/* ! */
var z = 1
if (n >1) {
// z !
i =2
while ( i <= n ) {
z=z*i
I
]
.
, . .
while, for, b r e a k
continue.
while , , break
continue.
do-while
do-while ( , )
, . :
do {
I
while ()
while do-while
, . .
, do.
do-while . while
, . while , .
,
for while.
1. JavaScript
46
.
/* */
var z =
i = 2
do{
z=z*x
i++
// z
I
w h i l e (i <= y)
!.
/* ! */
var z = 1
if (n >1) {
i = 2
// z !
do {
z=z*i
while ( i <= n )
1.5.8.
. , , ,
. .
, ( )
. , 5.2, ,
. ,
(, ""), . .
, ,
(, = " !"), JavaScript. , (, + 5),
.
. ,
, . , : +5 -3. +5 + -3,
, . , .
, ,
.
,
.
1.5.
47
( ). . ,
, .
. .
2
2
2
!
+ 3 *
<3 ||
<3 ||
2 <3
5
3 <1
3 <1 && false
|| 3 <1 && false
//
//
//
//
17, 2 5
true
true
false
. ,
, , , , , .
, , .
, . , , . . , , .
, . , . .
2 + 3 * 5
(2 + 3) * 5
((2 +3) + 4 * 5 ) / 2
(2 + 3) + 4 * 5 / 2
2 + 3 + 4*5/2
(2 + 3 + 4 ) * 5 / 2
2 + (3 + 4 * 5 ) / 2
(2 + (3 + 4 ) * 5 ) / 2
//
//
//
//
//
//
II
//
17
25
12.5
15
15
22.5
13.5
18.5
JavaScript. , , . , .
48
1. JavaScript
1.6.
, , . , , . , JavaScript
, .
JavaScript , , . ,
, , .
,
. .
, function,
, . 1.6.2.
,
:
_ ()
, . .
.
.
1.6.1.
JavaScript (
). , , , ( ) .
parselnt(crpoi<a, ) (8,10 16); , 10, .
parselnt("2 . 5")
parselnt("-17.875")
parselnt("1952")
parselnt("150 . " )
parselntC'ueHa 150 . " )
//
//
//
//
//
= 2
= -17
= 1952
= 150
= NaN
parseFloat(cTpOKa, ) ()
(8,10 16); , 10,
.
parseFloat("2.5")
// = 2.5
parseFloat("-17.875")
// = -17.875
1.6.
parseFloat ("1952")
pareseFloat("l.50px")
pareseFloat("")
49
// = 1952
// = 1.5
// = NaN
i s N a N () true, , false.
isNaN(123)
isNaN("123")
isNaN("Ten. 1234567")
isNaN("35 px")
isNaN(true)
isNaN(false)
isNaN("Bacfl")
//
//
//
//
//
//
//
false
false
true
true
false
false
true
1.3,
.
eval(cTpoKa) ;
JavaScript ( HTML).
var = 5
// 5
var = "if(y<10) { = +2}"
//
eval(x)
// 7
evalQ .
-, JavaScript. HTML- , eval():
<HTML>
50
1. JavaScript
1.6.2.
, ,
, . (), function. , :
function _()
I
:
function _() {
}
function _() { }
, . JavaScript. . () . ,
. ,
() .
, . , . , .
, ( ) () ,
. ,
function, .
, , .
, , return ,
. : , .
return . ,
1.6.
51
, return . .
, ( ).
Srectangle. :
function Srectangle(width, height){
S = w i d t h * height
return S
}
width
height, S, return
.
Srectangle , S:
function S r e c t a n g l e ( w i d t h , height){
return w i d t h * height
}
, , , , ( ) .
, ,
. :
_ ()
( )
. , ,
,
.
, .
JavaScript
. , ,
, ,
null. ,
.
SrectangleQ,
, .
, SrectangleQ,
,
, , .
S r e c t a n g l e ( 3 , 5)
/*
3x5 */
52
Srectangle(3, 4 + 2 )
height = 8
Srectangle(3, height)
1. JavaScript
/*
3x6 */
/*
3x8 */
width=4
height=5
Srectangle(widt, height + 2)
/*
4x7 */
Srectangle(2)
/* 0 (
) */
, , var. .
, .
1.
. ()
, . ,
.
2. .
,
,
.
var , ,
, .
var ,
, . , var
.
, ,
, .
, ,
, . , , ,
, .
, ,
.
1. S , :
1.6.
53
z = S r e c t a n g l e ( 2 , 3)
/* z S ;
S - */
2. 5 , :
function S r e c t a n g l e ( w i d t h , h e i g h t ) {
S = w i d t h * height
return 5
}
5 = 2
z = Srectangle(2, 3)
/* z 6,
5 2,
;
*/
3. , 2, van
function Srectangle(width, height){
var 5 = width * height
return S
}
var S =2
z = Srectangle(2, 3)
/* z 6,
S 2,
,
*/
4. :
function Srectangle(width, height){
var S = width * height
var x = 17
return S
}
z = Srectangle(2,3)
/* z 6;
S
;
*/
5.
:
function Srectangle(width, height){
v a r s = width * height
w i d t h = width + 10
// width
return s
I
width = 2
height = 3
z = Srectangle(width, height)
/* z 6;
width 2,
*/
, .
:
, - , ,
54
1. JavaScript
, , - .js. , .
! .
, , . ,
! : 1*2*3*...*, <=1. =0 =1 !=1. ! :
function factorial(n){
if(n <= 1) return 1
rezult = 2
// result -
for (i = 3; i <=n; i++) {
rezult = rezult*i
}
return result
}
, 12,
factorial(12).
factorialQ,
, :
var m = 10
= factorial(m)
// 3628809
. .
! .
function factorial(n){
if(n <= 1){
return 1
}
return n * f a c t o r i a l ( n - 1 )
}
// f a c t o r i a l ( )
, , ,
:
function factorial(n){
if(n <= 1) return 1
return
// f a c t o r i a l O
, ,
. ,
, , ,
.
1.7.
55
, ,
.
Function, . ,
arguments, ,
. ,
, .
arguments.
, 1.7.7.
1.6.3.
, . JavaScript .
, .
1. Srectangle(width, height) ,
width height.
b :
S3 = 0.5* Srectangle(a, b)
. S3.
2. :
if (Srectangle(a, b) > Srectangle(c, d))
alert(" ")
3. :
var = "25"
var = 12
var S = Srectangle(parselnt(x) , )
.
1.7.
,
.
, . JavaScript
. , .
, .
, . -
, JavaScript,
56
1. JavaScript
HTML- .
.
.
: . . .
. , .
. ,
.
,
, : _.. ,
.
.
. : _.(). ,
.
, , , , . , .
,
- -. , -, . .
, , , , . ,
, ,
, , .
. , .
JavaScript , ,
. - String (
), Array (), Math ( ) Date ( ). .
, , . , , . () , .
, . . , .
, Math,
Array, -
1.7.
57
, Array.
, , prototype (), . , , .
, . ,
, , . - ,
JavaScript .
1.7.1. String ()
String
. , , , , ,
. .
String .
. () ,
.
:
_ = new String("_")
_ . ,
mystring = new 5("!") mystring
"!".
:
_ = "_"
var _ = "_"
:
.
String.
.([])
String.([])
, -_
. ,
, , , .
58
1. JavaScript
String , ,
,
, , , ( String).
length , (
).
mystring = " "
mystring.length
// 30
" ".length // 30
function fstringO {return "abcde"}
/* ,
"abcde" */
fstringO.length // 5
. .
String
length , , ( )
; .
"".length
"".length
// 4
/* 11
(\ - ) */
= ""
//
.length
// 0 ( 0)
prototype (), , .
. .
function myFuncO {
//
return ""
I
// myName :
String.prototype.myNameO = myFunc
m y s t r i n g = " - " + " ".myNameO
/* mystring
" - " */
String
1. charAt(nHfleKc) , .
: .11()
.
() , 0.
1.7.
"".charAt(2)
"".charAt(15)
mystring = ""
mystring.charAt(mystring.length-1)
59
// ""
// ""
/*
"" */
2. charCodeAt([MHfleKc])
().
: . ])
.
IE4+ NN6 Unicode , NN4 ISO-Latin 1.
"abc" . c h a r C o d e A t O
"abc" . charCodeAt(l)
"abc" . charCodeAt(25)
"" . charCodeAt(25)
" " . charCodeAt(0)
//
//
//
//
//
97
98
NaN
NaN
1103
String.fromCharCode(97,98,1102)
/ / ""
4. concat(crpoKa) () .
: !.1(2)
.
, + :
! 2.
"".concat("")
= "" + " "
.concat("")
// ""
// " "
// " "
5. indexOf(cTpoKa_noMCKa [, ]) , , .
: '^(_ [, ])
.
_
. ( ) 0. , -1. -1.
0.
, , ,
.
60
1. JavaScript
substr()
(. ), .
.
=" "
.indexOf("")
.indexOf(" ")
.indexOf(" ")
.indexOf("")
.indexOf ("")
. i n d e x O f ( " " , 7)
x . i n d e x O f ( " ")
. i n d e x O f ( " " , 5)
.indexOf("")
//
//
//
//
//
//
//
//
//
3
3
-1
0
6
19
2
9
0
6. LastIndexOf(cTpoKa_noHCKa [, ]) , , ; ,
, 0.
: .LastIndexOf(crpoKa_noMCKa [, ])
. indexOfQ .
=" "
.lastlndexOf("")
x.lastlndexOf("")
.indexOf("a")
// 3
// 30
// 15
7. 11() Unicode,
.
: !. 11(2)
. : IE5.5+, NN6+.
, 0. ! , 2, , .
. . ,
IE5.5 IE6.0 1 -1, a NN6
Unicode.
8. (1 [, 2]) ,
, .
: .$(1 [, 2])
. .
, ! . .
0. , !
1.7.
61
2, . ,
.
slice() substr(). substringQ.
= " "
.slice(3,8)
// ""
.slice(3,-2)
// " "
/* */
= "mumuisigerasim.ru"
i = .indexOf("@")
_name = x . s l i c e ( 0 , i)
_domen = x . s l i c e ( i + l , . i n d e x O f ( " . " ) )
_domen = . s l i c e ( i + l , -3)
//
//
//
//
4
"mumu"
" g e r a s i m "
" g e r a s i m "
9. [, ]) ,
.
: . [, ])
.
, . , , , ,
.
, .
= " "
x . s p l i t ( " ")
/* - : "", "" */
.split("")
/* - : " " , " " , "" */
. s p l i t ( " " , 2 ) /* - : " " , " " */
10. substr(nHfleKC [, ]) ,
.
: .substr(nHfleKc [, ])
. .
, _ ! . .
0. , 1
, . sliceQ
HsubstringQ.
= " "
.substr(7,4)
// ""
/* */
= "mumu@gerasim.ru"
i = .indexOf("@")
// 4
_name = x.substr(0, i)
// "mumu"
_domen = .substr(i+1)
// "gerasim.ru"
62
1. JavaScript
11. substring(MHfleKd, 2) , .
: .5$(1, 2)
. .
: .
. 0.
, ,
. substrQ sliceQ.
= " "
.substring(0,6)
x.substring(7, .length)
. s u b s t r i n g ( 7 , 250)
. s u b s t r i n g ( 2 5 0 , 7)
//
//
//
//
""
""
""
""
= ""
.toLocaleLowerCaseO
.toLowerCase()
= ""
==
. t o l _ o w e r C a s e ( ) == . toLowerCase
// ""
// ""
// false
// true
= ""
. toLocaleUpperCase()
. toUpperCaseQ
= ""
==
. toUpperCaseO == . tollpperCase
// ""
// ""
// false
// true
63
1.7.
String
, - HTML. - . , - " !"
, HTML- :
<> !</>
JavaScript,
:
" !".bold()
boldQ .
,
. , write()
document HTML-. HTML- (. 1.11).
<1>
<SCRIPT>
= " !".bold()
document.wri te(x)
</SCRIPT>
<> J a v a S c r i p t
</HTML>
\. - Miuiosolt tntetnet
1: - ! 8
!
JavaScnpt
. 1.11.
document writeQ.
.
, HTML.
, , , ( ). , :
.()
.
.
64
1. JavaScript
("_")
blinkQ
bold()
fixedQ
1:1.(_,)
fontsize(4MOio 1 7)
italicsQ
1<( URL)
big()
smalt()
strike()
sub()
sup()
/* HTML-:
<A NAME="volume2">rnaea 2 < / A > */
" " . l i n k ( " h t t p : / w w w . a d m i ral.ru/~dunaev")
/* HTML-:
<A HREF = " h t t p : / w w w . a d m i r a l . r u / ~ d u n a e v " ) > </> */
. , .
String .
, .
. ,
, insstr. :
si, s2 .
:
function i n s s t r ( s l , s 2 ,n) {
return s i . s l i c e ( O . n ) + s2 + sl.slice(n)
}
insstr ("., " , " ", 7)
// ", "
i n s s t r ( " , " , " ", 100)
// ", "
,
. replacestr.
: si, s2
s3, s2 si (s2 si ).
, s2 si.
s2, . si s2, s3.
. :
function replacestr(si, s2, s3) {
var s = "
//
w h i l e (true) {
i = si.indexOf(s2)
// s2 si
if (i >= 0) {
s = s + sl.substr(0, i) + s3
si = sl.substr(i + s2.length)
}else break
//
//
1.7.
65
return s + sx
}
replacestrC'bacdae" , "a" , "X")
// "bXcdXe"
x = " "
replacestr (x , "" , "")
// " "
, s2 , , .
, .
, s2 ? , si , , , .
. , :
function replacestr (si, s2, s3) {
if (s2 == "")
s2 = " "
//
var s = "
//
while (true) {
i = si. indexOf (s2) // s2 si
if (i >= 0) {
s = s + sl.substr(0, i) + s3
//
si = sl.substr(i + s2. length)
//
}else break
//
>
return s + sx
}
(insstrQ replacestrQ)
, .
.js, . , . .
(, ) .
, JavaScript
.
( .js).
. . , " ".
, : . , . , N , N " " .
, -
66
1. JavaScript
. i, , , .
, , " ". , ,
String, .
ItrimQ, .
function Itrim(xstr){
if (!(xstr.indexOf(" ") == 0))
return xstr
/* ,
*/
var astr = xstr. split(" ")
//
var i = 0
while (i < astr.length){
if (!(astr[i] == ("")))
break
/* ,
*/
i++
}
astr = astr.slice(i)
//
return astr.join(" ")
//
}
rtrim() . , . , .
function r t r i m ( x s t r ) {
if ( ! ( x s t r . l a s t l n d e x O f ( " ") == x s t r . l e n g t h - 1))
return x s t r
1.7.2. Array ()
. ,
. , -
1.7.
67
. (
). ( )
. (). , 0,
, .
, . , , , , .
.
new:
_ = new Array([_])
_ , . , , .
, n u l l (
).
, . ,
new Array () Array.
Array length, . , _.length.
, ,
. , . ,
: _[]. .
earth, . ,
( ).
earth = new A r r a y ( 4 )
e a r t h [ 0 ] = ""
// 4-
68
1. JavaScript
JavaScript , , , .
,
earth = new A r r a y O
//
earth.xtype = ""
earth.xday = "24 "
earth.radius = 6378
earth.period = 365.25
, earth.radius. : earth["radius"].
.
, , .
. , , , .
, .
:
_[_1] [_2]
, , : , .
. , .
. , . . , . , "
2.1" 1- , 2- .
menu =
menu[0]
menu[l]
menu[2]
new A r r a y O
= new ' 1.1", " 1.2", " , " 1.3")
= new ' 2.1", " 2 . 2 " )
= new ' 3.1", " 3 . 2 " , " 3 . 3 " , " 3 . 4 " )
2- 3- , :
menu[2][l]
/ / " 3 . 2 "
,
, :
menu = new A r r a y O
/* : */
menu[0] = new A r r a y ( " ! " , " 2 " , "")
menu[l] = new A r r a y O
menu[l][0] = new ' 1.1". " 1.2", " 1.3")
menu[l][l] = new ' 2 . 1 " , " 2 . 2 " )
m e n u [ l ] [ 2 ] = new ' 3 . 1 " , " 3 . 2 " , " . 3 " , " 3 . 4 " )
1.7.
menu[0][l]
menu[0][2]
menu[l][1][0]
menu[1][2][3]
69
//
//
//
//
"
"
"
"
2"
3"
2.1"
3.2"
,
. ,
, , . . , , .
= new A r r a y ( 5 , 2, 4, 3)
=
//
[2] = 25
// 2
[2]
// 25,
[2]
.
, , ,
,
, :
= new ( 5 , 2, 4, 3)
= new ArrayO
for(i=0; i<a.length; i++)
{x[i] = a [i]}
//
/*
*/
Array
1. length , , ;
.
: _.length
, .
: myarray[mayarray.length]
= .
2. prototype (), .
, author :
Array.prototype.author = ""
Array, prototype ,
author :
myarray = new ArrayO
x a r r a y = new A r r a y O
A r r a y . p r o t o t y p e . a u t h o r = ""
// myarray
/ / x a r r a y
/*
*/
70
1. JavaScript
myarray.author = " "
/* author
myarray */
xarray.author = ""
/* author
xarray */
. Array.
. aSum(), .
. . , Sum aSum():
function a S u m ( x a r r a y ) {
var s = 0
for(i = 0; i <= x a r r a y . l e n g t h -1; i++){
s = s + xarray[i]
}
return s
I
// myarray 3-
/* (
) */
myarray.Sum(myarray)
/* Sum myarray,
*/
prototype. , :
s = aSum(myarray)
Array
Array ,
.
1. 1() , .
: _!.1(2)
. .
a.join(",")
// - "1,2,"
1.7.
71
8. 5$(1 [, 2])
.
: _.55(! [, 2])
. .
( ) , . ,
! . ! 2, . .
.slise(l,3)
a.slise(2)
// : 2, ""
// : "", "", ""
72
1. JavaScript
9. 50|1([_]) ()
.
: _.5:([_])
. .
, .
,
ASCII- . ,
. , 357 , 85,
, . . , sortQ
.
,
sortQ .
( ) .
,
, , . , , . (, 0 ), , sort() :
,
<0
^0
, ,
. null, Internet
Explorer .
10. (, [, ! [, 2 [, ...!^]]]) .
: _.5(, [, ! [, 2 [, ...]]])
. : IE5.5+.
.
, . , .
1.7.
73
= a.spli(1,3)
/* : "", "", 12
- : "", 5 */
spliceQ , , , .
, . spliceQ (), () . , ,
,
. spliceQ , ,
. , 0.
// - : "", "", 12
/ / - : "","", ", "",5
, : , , . , .
, :
function S(aN){
v a r S=aN[0]
for(var i = 1; i<= aN.length-1; i++){
S += aN[i]
return S
}
,
S(aN)/aN.length.
74
1. JavaScript
, :
function Nmin(aN){
var Nmin = aN[0]
for(var i = l ; i <= aN.length-1; i++){
if (aN[i] < Nmin)
Nmin = aN[i]
}
return Nmin
}
, :
function Nmax(aN){
var Nmax = aN[0]
f o r ( v a r i = 1; 1 <= aN.length -1; i++){
if (aN[i] > Nmax)
Nmax = aN[i]
\
/
return Nmax
}
,
:
function statistic(aN){
if (aN == 0 || aN == null || aN == "")
return new A r r a y ( 0 , 0 , 0 , 0 )
var S = a N [ 0 ]
var Nmin = aN[0]
var Nmax = aN[0]
for(var i = l; i<=aN.length-1; i++){
S += aN[i]
if (aN[i] < Nmin)
Nmin = aN[i]
if (aN[i] > Nmax)
Nmax = aN[i]
}
return new Array(S, S/aN.length, N m i n , Nmax)
}
statisticQ , .
, .
1.7.3. Number ()
-
, . ( top, left, width, height ). . , , .
, . , . .
JavaScript
JavaScript : .
.
, .
1.7.
75
, , .
, . , , . , , , . . .
JavaScript .
. , .
, . ,
, ,
.
2+3
111
2 + 3.6
// 5.6
2.4 + 3.6
// 6 -
6.00
//
,
: !2 !2. 110*">}.
15
// 100 000
26
// 2 000 000
1.5
// 1500
+1.5
// 1500
-1.5
// -1500
-4
// 0.0003
JavaScript ,
: 10 (), 16 () 8 (). , ,
, .
( ),
, ,
: , 1, 2,..., 9, , , , d, e, f ( ). ,
Ox4af 1199.
, 0 7. , 027 ( 23).
, .
. to!6()
, ,
. , 255 (
).
function tol6(nlO) {
hchars = "Q123456789abcdef"
/ , 16-
if (!0 > 255) return null
76
1. JavaScript
v a r i = n!0%16
var j = (nl0 - i)/16
rezult = "0x"
rezult += hchars .charAt ( j )
rezult += hchars . charAt (i )
return rezult
to!6(250)
// "0xfa"
to!6(30)
// "0xle"
to!6(30)+10
// "0xlel0" - ,
parselnt(to!6(30)) + 10
// 40
, += = + .
to!6() :
function to!6(n!0) {
. to2()
, , . . to2() . , var - , .
function to2(n!0) {
if (n!0 <2)
return " " + n!0
var i=n!0%2
var j=(nl0-i)/2
return t o 2 ( ] ) + i
}
//
, ,
parselntQ parseFloatQ
. . ,
, , ,
.
.
1.7.
77
parselnt("010", 10)
// 10
parselnt("010" , 2)
// 2
parselnt("010", 16)
// 17
, parseFloatQ IE6.0 , ( ).
, , .
"" + 25.78
// "25.78"
"" + 2 . 5
// "2500"
Number
, Number. , .
Number :
= new Number()
:
.
Number.
.[])
Number,([])
Number
MAX_VALUE ,
JavaScript (1.7976931348623157+308).
MIN_VALUE ,
JavaScript (5-324).
NEGATIVEJNFINITY - , , Number.MIN_VALUE.
POSITIVEJNFINITY - , , Number.MAX_VALUE.
NaN , N a N , JavaScript , (, )
(Not a Number).
prototype (), , String (. ).
Number
Number , ,
.
1. toExponential(KOflM4ecTBo) .
: )
. : IE5.5+, NN6+.
, ,
.
78
1. JavaScript
x=new Number(456)
x.toExponential(3)
x.toExponenttal(2)
x.toExponential(l)
x.toExponential(O)
2. 1:1() .
: 11()
. : IE5.5+, NN6+.
, ,
.
x=new N u m b e r ( 2 5 . 6 5 )
x.toFixed(3)
x.toFixed(2)
x.toFixed(l)
x.toFixed(S)
// 25.650
// 25.65
//2 5 . 7
// 25.7
3. toPredsion(T04HocTb) .
: .toPrecision(io4HocTb)
. : IE5.5+, NN6+.
, , ,
, .
x=new Number(135.45)
x.toPrecision(6)
// 135.450
x.toPrecision(5)
// 135.45
x.toPrecision(4)
// 135.5
x.toPrecision(3)
// 135
x.toPrecision(2)
// 1.4e2
x.toPrecision(l)
// Ie2
x.toPrecision(Q)
//
4. 151:([])
.
: .1:5([])
. , . 2 16 . , .
x=new Number(127.18)
x.toStringO
x.toString(10)
x.toString(16)
x.toString(S)
/ / "127.18"
/ / "127.18"
// "7f.2el47ael47b"
/ / "177.134121727024366"
x=new Number(5)
x.toString(2)
// "101"
1.7.
79
1.7.4. Math ()
Math
(, )
. Math :
Math.
Math.()
Math
Math .
F
LN10
10
LN2
2
LOG10E
( )
LOG2E
PI
SQRT1_2
- 1/2
SORT
2
,
Math.
var R = 10
//
circus = 2*R*Math.PI
//
Math
() ( ) ;
$() ;
51() ;
atan(4HOio) ;
atan2(x, ) ;
cei(.() ;
$() ;
() ;
() ;
1() ;
(1,2) !, 2;
1(1,2) !, 2;
\/(!,2) ! 2;
random() 0 1;
!() ;
sin () ;
sqrt(4Mcno) ;
1() .
80
1. JavaScript
1. randomQ , 0 1.
0 Nmax,
:
= Nmax'Math.randomf)
Nmin Nmax,
:
= Nmin + (Nmax - N m i n ) * M a t h . r a n d o m O
:
function rand(a, b) {
return a+ (b-a)*Math.random()
}
, , () -, . .
2. sin(x), , :
Math.sin(Math.PI*x/180)
JavaScript -,
. , .
, .
. , . xl 2 . ,
2 + + 0. { 2
2 + + = 0.
,
. ,
. .
. , , . . , .
, , ,
. , ,
, .
, ( beqQ)
a, b
. . , ,
1.7.
81
. .
,
. , , (null).
:
function beq(a, b, ) {
//
v a r aret = new A r r a y O
v a r D = b*b - 4 * a * c
if (a == 0) {
if ( ! ( b == 0)){
aret[0] = -c/b
a r e t [ l ] = null
} .
return aret
//
}
if (D == 0) {
//
aret[0]=-b/2/a
aret[l]=aret[0]
}
if ( D > 0 ) {
//
a r e t [ 0 ] = (-b - M a t h . s q r t ( D ) ) / 2 / a
a r e t [ l ] = (-b + M a t h . s q r t ( D ) ) / 2 / a
}
return
}
beq(0,
beq(l,
beq(3,
aret
:
2, 6)
// (-3, null)
-2, 1)
// (1, 1)
4, -2.5)
/* (-1.797054997187545,
0.4637216638542114) */
beq(2, 0. 5)
//
/ ()
b , = f(x),
() , (/) b (). . , , ,
, .
,
. , , . . ,
, .
.
.
. ,
, . : , .
82
1. JavaScript
. : ab , ,
. . , ,
.
,
.
.
? eval(), JavaScript, . integralQ , f(x),
, "5** + 10". , . integralQ:
function integral(expression, a, b){
//
v a r x , yl, y 2 , n , length, d x , 5 = 0
length = M a t h . a b s ( b - a)
n = 100
//
dx = length/n
//
=
/*
*/
yl = eval(expression)
= + dx
2 = eval(expression)
S = (yl + y 2 ) ' d x / 2
for(i=2; i<=n;i++){
yl = 2
x = x + dx
y2 = eval(expression)
S+= (yl + y2)*dx/2
return S
}
, :
integral("x", 0, 1)
/" 0.5090000000000002
( = 0.5) */
integral("x*x" , 0, 1)
/* 0.33335000000000037
( = 0.3333...) */
integral("x*x" , 0, 10)
/* 333.34999999999917
( = 333.3333...) */
, n ab.
n = 100 . , . :
2, n , n 100. , , . :
function i n t e g r a l ( e x p r e s s i o n , a , b){
if ( ( e x p r e s s i o n || !b&&!a)
//
1.7.
83
return 0
if (a == b)
return 0
var x, yl, y2, n, length, dx,S=0
length = Math.abs(b - a)
yl = Math.min(a.b)
//
b = Math.max(a, b)
//
= yl
n = 100
if (length>2) n=Math.round(100*Math.log(length+l))
dx = length/n
//
x = a
/*
*/
yl = eval(expression)
x = + dx
2 = eval(expression)
S = (yl + y2)*dx/2
for(i=2; i<=n;i++){
yl = y2
x = x + dx
y2 = eval(expression)
S+= (yl + y2)*dx/2
}
return S
}
:
integral("x*x", 0, 10)
/ 333.33749999999906
( = 333.3333...) */
,
.
() / ()
, . , / ()
, /() t
.
: , ,
.
, . ,
.
,
evalQ, ,
. DydxlQ , , , "25* - 2". ,
. :
function D y d x ( e x p r e s s i o n , ) {
if ( ( e x p r e s s i o n )
/ /
//
84
1. JavaScript
return 0
var x, , dx
dx = 0.000025
x = a - dx
// 1-
= eval(expression)
x = a + dx
// 2-
return (eval(expression) - y)/2/dx)
}
:
Dydx("x",l)
// 0.9999999999998899 ( 1)
Dydx("x*x", 1)
// 1.9999999999997797 ( 2)
() f(x) (0, /0), ,
^ /(:)
. , .
extremumQ, ,
(
).
,
, , 0.
, eval(), , . extremumQ
, , , "5** - 2*".
,
0. , . :
function extremum(expression, a, b, d){
//
if (!d) d = 0.001
var x, yl, y2, i
x = a
yl = Dydx(expression, a)
i = 1
while ((x <= b)&&(i <= 1000)) {
y2 = Dydx(expression, x+d)
if ((yl<0)&&(y2>=0)||(y2<0)&&(yl>=0)) {
x=x+d*Math.abs(yl)/(Math.abs(yl)+Math.abs(y2))
return new Array(x, eval(expression))
)
x+= d
1 = 2
i++
}
return new ArrayO
}
:
extremum("x*x-l",-l, 1, 0.01)
/* (7.528699885739343e-16, -1)
(0, -1) */
1.7.
85
,
, .
1.7.5. Date ()
, , , . .
. , , , .
, . , ( ),
. , , - 5 . ,
19 . ,
. ,
. (Greenwich Mean Time
GMT). GMT UTC
(Universal Time Coordinated ).
, GMT. , .
. GMT.
, ( ). , , GMT, , , .
JavaScript 30.10.2002,
, . Date.
, 31 30 , 366 .
:
= new D a t e ( [ ] )
, . , , -
(, ).
86
1. JavaScript
Date.
:
= .
, , ,
:
= .(_)
:
xdate = new DateQ
/* ,
*/
Year = xdate.getYear()
/* Y e a r
*/
Year = Year + 3
/* Y e a r
,, , 3 */
xdate.setYear(Year)
/*
*/
new DateQ,
, .
:
new Date("Mecflu, , ::")
new .(" , ")
new Date(rr, , , , , )
new Date(rr, , )
new .()
,
. . . . ,
0 (). . ( ). . 10, , 0 (. 3:05:32).
, .
,
, 1 1970 ( 00:00:00). ,
, , .
Date
,
, Date (. 1.3). , :
= new Date([])
, () ,
: .([]).
1.7.
87
:
( get) ( set). UTC.
(, , , , , , ).
1.3. Date
getFuUYear( )
1970-.. .
getYear( )
70-...
getMonth( )
0-11
( = 0)
getDate( )
1-31
getDay( )
0-6
( = 0)
getHours( )
0-23
24-
getMinutes( )
0-59
getSeconds( )
0-59
getTime( )
0-...
getMHliseconds( )
0-...
getUTCFuLlYear( )
1970-.. .
UTC
getUTCMonth( )
0-11
UTC ( = 0)
getUTCOate( )
1-31
UTC
getUTCDay( )
0-6
UTC ( = 0)
getUTCHours( )
0-23
UTC 24-
getUTCMinutes( )
0-59
UTC
getUTCSecondsQ
0-59
UTC
getUTCMilliseconds( )
0-....
setYear(3H34)
1970-.. .
()
SetFuUYear(3H34)
1970-...
setMonth(3Ha4)
0-11
( = 0)
setDate(3H34)
1-31
setDay(3H34)
0-6
( = 0)
setHours(3H34)
0-23
24-
setMinutes(3H34)
0-59
setSeconds(3H34)
0-59
setMiLliseconds(3Ha4)
0-...
setTime(3H34)
0-...
setUTCFuLLYear(3H34)
1970-.. .
UTC
1. JavaScript
88
1.3 ()
setUTCMonth(3H34)
0-11
UTC ( = 0)
setUTCD3te(3H34)
1-31
UTC
setUTCDay(3H34)
0-6
UTC ( = 0 )
setUTCHours(3Ha4)
0-23
UTC 24-
setUTCMinutes(3H34)
0-59
UTC
setUTCSeconds(3Ha4)
0-59
UTC
UTC 1.1.70 00:00:00
GMT
setUTCMilliseconds(3H34)
getTimezoneOffset ()
0-...
GMT/UTC
toDateString()
( )
(IE5.5)
toGMTString()
toLoc3leDateString()
(NN6, IE5.5)
toLocaleString()
toLocaleTimeString()
(NN6, IE5.5)
toString()
toTimeString()
(IE5.5)
toUTCString()
D3te.parse("dateString")
Date.UTC(3H34)
GMT
, , , UTC. ,
, . UTC , .
, , , , 0. . 11- , 12-, . (Sunday) 0- , 7-.
XX 1900. , 1998 98. 1900
1999 . , 2002 -
1.7.
89
, 2003 .
today = new Date()
Year = today.getYearO
today = new Date(98,11,6)
Year = today.getYearO
today .getFullYearO
//
// 2003
/* today
6 1998 , 00:00:00 */
// 98
/ / 1998
'
, set.
.
, . .
.
mydate = new Date(1952,
myday = mydate. getDayO
mydate.setYear(2003)
myday = m y d a t e . g e t D a y O
10,6)
//
//
//
//
15.5+ NN6+
:
mydate = new DateO
mydate. t o L o c a l e D a t e S t r i n g O
mydate.toLocaleTimeStringO
, ,
toLocalDateStringO toLocalTimeStringQ, . -, , .
,
. , , , . .
90
1. JavaScript
1. , :
week = 1000*60*60*24*7
/*
- 604800000 */
mydate = new Date()
//
mydate_ms = mydate.getTimeQ
/* ,
1.01.1970 00:00:00 */
mydate_ms += week
// maydate_ms = mydate_ms + week
mydate.setTime(mydate_ms)
/*
mydate */
newdate = mydate. toLocaleStringO
//
2. , 10 2003
5 2003. :
datel = new, Date(2003 ,01,10)
date2 = new Date(2003,02,5)
datel dateZ , (, Mon Feb 10 00:00:00 UTC+0300 2003). , parse() Date.
Date.parse(date2) Date.parse(datel)
:
days = (Date.parse(date2) - Date.parse(datel))/1000/60/60/24
// : 23
/* ,
strdate
*/
/* */
mydate = new D a t e ( a s t r d a t e [ 2 ] , a s t r d a t e [ 1 ] - 1 , a s t r d a t e [ 0 ] )
4. , ,
, ,
".. ::"
. , , , . , , .
, .
function mydate(strdate){
if (strdate == "" || strdate == null) {
return new Date()
}
var astrdate = strdate.split(" ")
1.7.
91
if ( a s t r d a t e . l e n g t h == 1)
astrdate[l] = "00:00:00"
astrdate[0] = astrdate[0].split(".")
astrdatefl] = astrdate[l].split(":")
if ( a s t r d a t e [ l ] . l e n g t h == 1)
a s t r d a t e [ l ] = new A r r a y ( a s t r d a t e [ 1 ] [ 0 ] , " 0 0 " , " 0 0 " )
else {
if ( a s t r d a t e [ l ] . l e n g t h == 2)
astrdatefl] = new A r r a y ( a s t r d a t e [ l ] [ 0 ] , astrdate[1][1] , "00")
}
return new D a t e ( a s t r d a t e [ 0 ] [ 2 ] , a s t r d a t e [ 0 ] [1]-1, a s t r d a t e [ 0 ] [2] ,
astrdate[l][0]. astrdate[1][1] , a s t r d a t e [ 1 ] [ 2 ] )
}
, return .
mydateQ
:
datel = m y d a t e ( " 1 0 . 2 . 2 0 0 3 " )
date2 = m y d a t e ( " 5 . 3 . 2 0 0 3 " )
days = ( D a t e . p a r s e ( d a t e 2 ) - D a t e . p a r s e ( d a t e l ) ) / 1 0 0 0 / 6 0 / 6 0 / 2 4
, -, (), . , , .
, , ,
(). ,
setlntervalQ . .
1.7.6. Boolean ()
Boolean :
= new 1(_)
prototype, toStringQ Of(),
String Number.
prototype String
Array. Boolean ,
, new Boolean,
(
prototype).
1.7.7. Function ()
Function
:
function _() {
92
1. JavaScript
,
new Function.
Function:
_ = new Function(["napl", [."napN"]. "!; [;
]")
.
. , .
, Function,
: _().
// 6
a = "width"
b = "height"
expr = " v a r s = w i d t h * h e i g h t ; return s"
Srectangle = new F u n c t i o n ( a , b, e x p r )
Srectangle(2, 3)
//
, new,
Function,
.
Function
1. arguments , .
0. ,
Array ( , length
).
arguments ,
, . ,
, ,
("", 0, null) . . .
: _.arguments.
, , , , ( !).
function m y f u n c ( a , b , c ) {
var arglenth=myfunc.arguments.length
/*
*/
var x=""
for (i=0; i< myfunc.arguments.length;i++) {
1.7.
93
/ / " 5 , , : 2 "
// ": 0"
// "null , , 0 , 2 5 , : 4"
2. Length , .
: _. length
arguments, .
function m y f u n c ( a , b, , d){
function fl() {
f2()
}
function f2()
a l e r t (f2 .caller)
// f 2 . caller
fl() f2(),
, fl() (. 1.12).
Function
toString() .
: _.15()
94
1. JavaScript
. 1.13.
IMiciosoft Internet fxptr.1. ;
Iff f \
mssx*
OK
'1
. 1.13. alert(myfunc.toString())
apply( [_ [, _]])
call( [_ [ ,napl[,2[
napN]]]])
.
. , ,
. ,
.
1.8, . ,
.
,
. ,
. , 1.8.
/* - ()*/
function car(name, model, color) {
this.name = name
//
this.model = model
//
his.color = color
//
t h i s . s h o w = showcar
//
I
/* , car */
function s h o w c a r ( ) {
a l e r t ( t h i s . n a m e + " - " + this.model)
//
I
/* car */
mycar = new c a r ( " " , " B A 3 2 1 0 5 " , " w h i t e " )
show car ( ) :
mycar.show()
1.7.
95
showcarQ,
. this, .
apply() callQ showcarQ mycar. , ,
showcar .
showcar callQ, mycar :
showcar.call(mycar)
catlQ ,
. , )
applyQ.
1.7.8. Object
Object , JavaScript, String, Array, Date . .
. .
1
function _ ([napl,...[, napN]){
>
3
= {!: ! [, 2: 2 [ N]}
:
__.
__.([])
, , , , , , ,
. . , . :
function (, , , ) {
this. =
this. =
this. =
this. =
}
,
. this , . this, -, . ,
96
1. JavaScript
,
, . ,
agentOO?:
agentOO? = new ( " " , 5, " 2 2 3 - 3 3 2 " , 3600.50)
:
007.
// " "
agent007.
// 3600.5
:
S h t i r l i t z = new ( " " , 4, " 1 2 3 - 4 5 6 7 " , 4500.50)
,
. prototype, String Array. toStringQ
. hasOwnPropery("cBoiicTBo") , , , (
prototype). , true, false.
.
, ,
, .
1.8.
, JavaScript . new ,
. , prototype ,
. , -,
.
. ?
. , . - , ,
. ( Array):
.
, ,
. , . , , - .
- ,
.
1.8.
97
1.8.1.
JavaScript .
.
,
.
, - . , , ? , , . ,
.
- . . this (): this..
-,
() (), model () color ():
function car(name, model, color) {
this.name = name
this.model = model
this.color = color
}
car. , ,
. ,
new:
mycar = new ( " 0 " , "31111","white")
, mycar, . .
mycar :
mycar.model
mycar.name
mycar.model = "311113"
// "31111"
// " "
// "311113"
, ( : .).
new ObjectQ:
mycar = new O b j e c t O
mycar.name = ""
mycar.model = "BA31111"
mycar.color = "white"
: Object, , , Array.
:
mycar = { : " 0 " , model:"BA31111", c o l o r : " w h i t e " }
. =
= , .
98
1. JavaScript
,
, , (
null, 0 ""). ( ||) :
function car(name, model, color) {
//
this.name = name || ""
this.model = model || ""
this.color = color || " b l a c k "
}
//
//
//
//
mycar car
""
""
"black"
1.8.2.
, ,
prototype. (), mycar, prototype owner
() :
function car(name, model, color) {
// car
this.name = name || "."
this.model = model || ""
this.color = color || "black"
}
mycar = new car("","")
/* mycar
car */
mycar.name
// ""
mycar.model
// ""
mycar.color
// "black"
car.prototype.owner = ""
//
mycar.owner
// ""
(
), :
._ =
, .
function c a r ( ) { }
mycarl = new car()
mycar2 = new car()
mycarl.name = ""
mycar2.model = "BA32106"
mycarl.name
mycarl.model
mycar2.name
mycar2.model
//
//
//
//
""
undefined ( )
undefined ( )
"BA32106"
1.8.
99
1.8.3.
.
: , , . , photo, URL-
. , , , photo.
photo. photo
, , photo.
function car(name, model, color, photo) {
// car
this. name = name
this. model = model
this. color = color
this. photo = photo
// photo
function photo (name, url) {
this. name = name
thi s . url = url
// photo
, photo:
photol = new photoC'OKa" , "/images/okal . j pg")
photo2 = new photoC'OKa" , "/images/oka2 . gi f" )
car:
mycar = new ("0", "31111" . "white" . photol)
mycar. photo. url
// "/images/okal . j pg"
mycar. model
// "BA31111"
mycar = new ("0", "31111" , "white" , photo2)
mycar . photo . url
// "/images/oka2 . gi f "
mycar. model
// "BA31111"
: URL-
, mycar, u r L
photo, mycar , , mycar.
1.8.4.
,
.
: name (), model (), regnum (), owner ()
photo (). ,
, , (,
). , , . -
100
1. JavaScript
,
, , , .
: , (, URL- ).
(, , 32101 ),
. ref:
function ref(name, model, url) {
/*
*/
t h i s . n a m e = name
//
this.model = model
//
this.url = url
// URL-
}
.
( aref).
ref:
aref = new A r r a y O
//
aref[0] = new r e f ( " " , "2101", " p i c t 0 . g i f " )
aref[l] = new r e f ( " " , "210", " p i c t l . g i f " )
a r e f [ 2 ] = new r e f ( " B c w i r a " , " 3 2 4 " , " p i c t 2 . g i f " )
a r e f [ 3 ] = new r e f ( " O K a " , "Basllll" , " p i c t 3 . g i f " )
.
. ,
.
, ref.
, - :
function car(regnum, owner, ref) {
this.regnum = regnum
//
t h i s . o w n e r = owner
//
t h i s . r e f = ref
//
}
.
:
a c a r = new A r r a y O
a c a r [ 0 ] = new c a r ( " A 1 2 3 B X " ,
a c a r [ l ] = new c a r ( " M 3 4 5 C T " ,
a c a r [ 2 ] = new c a r ( " E 6 7 8 C A " ,
a c a r [ 3 ] = new c a r ( " K 0 5 6 0 X " ,
a c a r [ 4 ] = new c a r ( " K 8 9 5 M X " ,
a c a r [ 5 ] = new c a r ( " P 3 4 0 H Y " ,
a c a r [ 6 ] = new c a r ( " 0 3 2 1 0 K " ,
"", aref[l])
"", aref[l])
"", a r e f [ 0 ] )
"", a r e f [ 2 ] )
"", aref[3])
"", a r e f [ 2 ] )
"", a r e f [ 2 ] )
7 . 32106 ,
324 , . ,
.
:
1.8.
101
[4].ref.model
// "31111"
[3] .ref.name
// ""
[3].owner
// ""
,
Array () . .
, ,
. HTML , . ,
<TABLE>, <TR>, <TH>, <TD> . HTML- , <SCRIPT> </SCRIPT>, JavaScript. .
. ,
.
JavaScript,
, writeQ
document HTML- .
,
. ,
HTML- . , () .
1.1 HTML-, . . ,
(. 1.14).
- - Microsoft Internet E
(;! !
;JA123BX |
( ||45"
678 |
:|
|5210 '
I I
| 5| (
. 1.14.
102
1. JavaScript
1.1.
<1_>
<><11_> </11></>
<SCRIPT>
/* */
function ref(name, model, url) {
*/
//
this.name = name
//
this.model = model
// URL-
thi s.url = url
I
/*
function car(regnum, owner, ref) {
*/
//
this.regnum = regnum
//
this.owner = owner
//
this.ref = ref
/* */
aref = new A r r a y O
//
aref[0] = new ref("", "2101", "pict0.gif")
aref[l] = new ref("" , "2106", "pictl.gif")
aref[2] = new ref("Bonra", "324", "pict2.gif")
aref[3] = new ref("", 'Basllll", "pict3.gif")
acar = new ArrayO
acar[0] = new car( "A123BX" "", aref [1])
acar[l] = new car( "M345CT" "", aref[l])
acar[2] = new car( "E678CA" "", aref[0])
acar[3] = new car( "K0560X" "", aref [2])
acar[4] = new car( "K895MX" "", aref[3])
acar[5] = new car( "P340HY" "", aref[2])
acar[6] = new car( "03210K", "" aref[2])
strTab = "<TABLE BORDER=1> <TR>"
strTab += "<>
"<></><> </> <TH>Baee</TH></TR>"
/* */
for(i=0;i<=acar.length-1;1++){
strTab += "<TR><TD>" + acar[i].ref.name + "</TD><TD>" +acar[i].regnum
strTab += "</TD><TD>" + acar[i].owner + "</TD></TR>"
strTab += "</TABLE>"
document.write(strTab)
strTab
HTML- */
</SCRIPT>
</HTML>
for +=. , += = + .
,
.
. ,
strTab
:
"<TD><IMG SRC = "' + acar[i] . ref .url + '
103
1.9.
1.9.
, JavaScript . , - . .
.
1.9.1.
()
. ,
32. , .
, .
. . 1.4 .
1.4.
,
,
,
X&Y
X|Y
XAY
1
1
104
1. JavaScript
, 2&3 2, 2(3 3. , 2
10, 3 11. &
10, 2, | , 3.
, ,
. , 32 12,
11 ( 3) 1100,
12. 2 1.
, 6 110;
1 , .
1.9.2.
(delete)
,
delete. :
delete
, , .
m y a r r a y = new Array("","b"."","d")
myarray.length
// 4
delete myarray[l]
myarray.length
// 4
myarray[0]
// "a"
myarray[l]
// undefined
myarray[2]
// "c"
myarray[3]
// "d"
delete .
JavaScript, ,
.
(in)
,
. , .
. , true, false. ,
in ( if, switch,
for, while, do-while).
1.9.
105
"write" in document
/ / t r u e
2. .
function (, , , )
t h i s . =
this. =
this. =
this. =
I
// true
// false
in 15.5+, NN6+.
(instanceof)
, JavaScript. ,
, Array, String, Date . . instanceof true false , ,
( if, switch, for, while,
do-while).
Array, Object.
m y a r r a y = new A r r a y Q
myarray instanceof Array
Array instance Object
Myarray instanceof String
//
//
//
true
true
false
in 15.5+, NN6+.
1.9.3.
(?:)
i f . . .
else... : .
,
. :
? ! : 2
:
= ? ! : 2
!, , 2.
d = new D a t e ( )
= d.getDateO
t y p e d a t e = (x%2 == 0)&&(x > 1) ? ""
""
106
1. JavaScript
JavaScript , , if, ,
, . :
function iff(condition, exprl, expr2){
if (condition)
return eval(exprl)
else
return eval(expr2)
}
if,
. . : , , . .
(tipeof)
,
: string, number, boolean, object, function undefined. ,
typeof, . . typeof.
var x
= 3.14
N = new Number(3.14)
s = " !"
a =new A r r a y ( l , 2, 3, 4, 5)
function f ( ) { }
typeof
typeof
typeof
typeof
typeof
typeof
x
n
N
s
a
f
"undefined"
' "number"
"object"
"string"
"obj ect "
// "f uncti on"
1.10.
, ,
, ;
.
(. 1.6).
, , . . .
, ,
, . JavaScript
.
107
1.10.
. , , .
, .
1.6.
function()
()
new
typeof
void
delete
( )
()
( )
( )
,_
&
()
10
12
9
!1
&&
()
108
1. JavaScript
1.6 ()
13
14
( )
%=
=
5=
&=
1_5
( )
, , , ,
. ,
,
, . ,
&& ;
false, , ,
false. , ||
true, , , true.
,
. - , , .
1.11.
JavaScript, , , ,
, (. 1.7). , , - (, )
.
109
1.11.
interface , ,
. : myinterface, xlnterface . .
, , - . JavaScript , .
,
. ,
.
,
. ,
( ) .
1.7.
abstract
else
int
super
boolean
extends
interface
switch
break
false
long
synchronized
byte
final
native
this
case
finally
new
throw
catch
float
null
throws
char
for
package
transient
class
function
private
true
const
goto
protected
try
continue
if
public
typeof
default
Implements
reset
var
delete
import
return
void
do
in
short
while
double
instanceof
static
with
2.
, , JavaScript .
, . 4 , ,
, . ,
3.
2.1.
-, 1950 I960 , - . , ,
, GO TO ( , ). , . GO TO
, . . , Assembler
. 3-5 . , . , ?
. , , .
80-
, , .
1960 1975 , FORTRAN ALGOL. , . ,
,
2.1.
111
, .
,
. GO TO - ,
, , ,
. .
70- , , , ,
.
. . . PL/I .
. ,
: ,
, , . .
, . , , : ? , .
1990 - (). ,
. , , . , .
. , , .
(, , ),
,
. , , ,
. ,
, , , .
() . , ,
.
.
C++. (
) , . , . C++, ,
() . (, Java Object Pascal), C++ - -. -
112
2.
2.2. HTML
113
, . , .
, .
JavaScript , , , , .
, , JavaScript. , , - . .
, JavaScript,
. ,
, .
JavaScript , .
: JavaScript , , HTML. ,
,
. , HTML,
, JavaScript , -.
, , JavaScript,
. , JavaScript, .
, JavaScript Java . Java
C++, , ,
.
2.2. HTML
2.2.1. HTML
- HTML (Hyper Text
Markup Language ).
,
, . , , , , . , . ,
(, Windows) HTML
htm html, -, Microsoft Internet Explorer Netscape Navigator.
HTML , . (< >). , -
114
2.
. , . (). . , , .
:
<_ [1 [= ! ] . . . [ [= ] ] >
, . (, <BR>),
(, NORESIZE <FRAME>).
, , . , <IMG SRC = "picture.jpg">
picture.jpg. IMG , SRC , a "picture.jpg" (). ID , , , .
,
. , Enter,
. , .
. .
< .. .> </>.
, .
.
, <BODY>, < . . .>, <DIV>,
<TABLE> . , </BODY>, </A>, </DIV>, </TABLE>. <>,
, <> </>. , <>
<IMG>, :
< HREF = " w w w . y a n d e x . r u " > < I M G SRC = " b a n n e r . g i f " > < / A >
115
2.2. HTML
<HTML>
<1> -</1>
<IMG SRC="pict. jpg"> ,
< HREF = "www.admiral.ru/~dunaev">Caiu </>
<FORM>
<INPUT TYPE="text" VALUE="">
<p>
<> </1>
</FORM>
</HTML>
. 2.1 HTML- , HTML-.
--.! -. * fs
*
Web-
<1_>
<1> -</1>
<IMGSRC='pict.jpg'>
< HREF = 'wwv. admiral, ru/~dunaev'>Ca(vr </> ;'
<FORM>
- <INPUTTYPE = 'text' VALUE = ">
<1> </>
</FORM>
</HTML>
116
2.
2.2.2. HTML
, , , HTML.
,
-. -, . -,
HTML- . -, HTML-,
, ( , ). , , HTML- ( ).
CSS (Cascading Style Sheets ). ,
, STYLE.
. STYLE
<STYLE>. <STYLE> ,
. -
CLASS = _.
,
( ) ,
. , ,
CSS. top left,
, , z-index . , top left
, , . ,
( HTML-), z-index.
, , HTML-
<OBJECT> <EMBED>. HTML- , ,
Flash-, , .
HTML- , , , - HTML . ,
, (scripts). JavaScript. . Microsoft Internet Explorer JavaScript
VisualBasicScript, Netscape Navigator.
JavaScript HTML- ?
, HTML-
. JavaScript HTML . , 1. ,
2.3. ,
117
, , .
.
2.3. ,
2.3.1.
, HTML-, .
JavaScript. , JavaScript, , ,
, . JavaScript, -, , .
, . , ,
, .
, JavaScript . ?
JavaScript,
HTML-. .
HTML-, , HTML-.
HTML-, . ,
, .
, .
, ,
. , HTML-,
HTML-, -.
HTML- . , - .
.
. .
. . , . : .
. , .
<SCRIPT>,
<SCRIPT> </SCRIPT>. <SCRIPT>, , . </SCRIPT> , . , ,
HTML-. <SCRIPT>
HTML- .
HTML-, .
118
2.
<SCRIPT>, , .
LANGUAGE ; :
a "JavaScript", "JScript";
"VBScript", "VBS".
LANGUAGE , Internet Explorer JScript.
SRC ( URL-), .
, HTML, .
<SCRIPT LANGUAGE="JavaScript">
...
</SCRIPT>
//
. , Internet Explorer 4.0 Netscape Navigator 4.0 JavaScript 1.2. JavaScriptl.5, Internet
Explorer 6.0 Netscape Navigator 6.0. JavaScript
LANGUAGE , ,
. , ,
,
.
\
JavaScript Internet Explorer JScript.
Internet Explorer LANGUAGE = "JavaScript". Netscape Navigator LANGUAGE = "JavaScript", LANGUAGE =
"JScript" . , , LANGUAGE =
"JavaScript". , ,
, ( ).
, JavaScript, <SCRIPT>
</SCRIPT>, , ,
HTML-. .
, <!-- -->. , , , ,
( ), , . :
<SCRIPT LANGUAGE="JavaScript" >
< ! -//
//-->
</SCRIPT>
, . JavaScript --> HTML,
. , , -
2.3. ,
119
. , .
, , , <SCRIPT>
</SCRIPT> . , JavaScript
. ,
, , , js.
( ), , HTML- . , ,
HTML-. :
<1_>
<SCRIPT>
function myfunc(){
}
</SCRIPT>
</HTML>
HTML- () ,
. .
, , .
. 2.3.2.
, <SCRIPT>.
<SCRIPT>, , . , , HTML- .
HTML-:
<HTML>
<HTML>
<SCRIPT>
function myfunc(){
. . .
}
</SCRIPT>
<SCRIPT>
. . .
myfuncO
</SCRIPT>
</HTML>
<SCRIPT>
. . .
myfuncO
</SCRIPT>
<SCRIPT>
function myfunc(){
. . .
}
</SCRIPT>
</HTML>
120
2.
<HTML>
<HTML>
<SCRIPT>
<SCRIPT>
function myfunc(){
myfuncO
function myfuncOf
myfuncO
</SCRIPT>
</SCRIPT>
</HTML>
</HTML>
, ,
HTML-, HTML. <HEAD> ( ). .
, HTML, . -,
HTML-. -, - onload <BODY>, HTML-. onload , . , ,
<SCRIPT>, HTML- <HEAD>.
, - onload <BODY>
, <BODY>, . :
<HTML>
<HEAD>
<SCRIPT>
function myfunc () {
!
</SCRIPT>
</HEAD>
<BODY onload = "myfuncO ">
2.3. ,
121
</BODY>
</HTML>
2.3.2.
( ) HTML , , ,
, . . HTML , , .
. ,
. , onclick;
onchange; onmouseover ,
HTML-. . - HTML , , . , HTML- ,
, myfuncQ:
<2 onclick = "myfunc()"> < / 2 >
,
. ,
-. , , . .
, -, , ,
. .
onclick
myfuncQ. , .
<1>
<SCRIPT>
function _(){
function _1).(){
</SCRIPT>
< -"_1(1">
< ="_()">
< ="_">
</1_>
. 2.2.
122
2.
function clickimageQ {
alert("!")
}
</SCRIPT>
<IMG SRC = " p i c t . j p g " onclick = "clickimageQ ">
</HTML>
2:
<HTML>
<IMG SRC = "pict.jpg" onclick = "alert(" ! " ) " >
</HTML>
HTML- , -. ,
.
, JavaScript, - "javascript:". , <IMG onclick = "javascript: 1:("!")">. , JavaScript.
2. . , , HTML ID ().
,
. ID ,
-. <SCRIPT>
, :
_10.()
<HTML>
<1 ID = "1"> ! < / 1 >
<SCRIPT>
function Myheader.onclick(){
alert("!")
}
</SCRIPT>
</HTML>
2.3. ,
123
, HTML- ID,
.
. ,
, .
.
, :
HTML- , - .
-
.
, ,
, -:
function document . () {
}
( ) - . , IE 4.0 . FOR
EVENT <SCRIPT>.
FOR ,
, EVENT .
, ID.
<HTML>
<SCRIPT FOR = "MYBUTTON" EVENT = " o n c l i c k " >
alertC'Bbm ")
</SCRIPT>
<BUTTON ID = ""> </>
</HTML>
<SCRIPT>
, EVENT, , FOR. (<BUTTON . . .>)
.
- .
.
, ( <SCRIPT>), .
124
2.
2.4.3 .
2.3.3. ,
,
. , -. , . - .
HTML-, . , , . ,
HTML- . ,
( HTML-), .
HTML- .
window, a HTML-, ,
document. . ,
document window. HTML-
, document. , .
,
, .
1 JavaScript ,
. ,
. , , , .
:
.
.()
(). , , . , - , .
, . ,
. , :
!.2. . . .
( ),
:
!.2. . . . oeN.
!.2. . . . .
( , ). ,
:
( );
(-);
( , ).
2.3. ,
125
d o c u m e n t window,
HTML-, () , : window.document. document write(crpoKa),
HTML- ,
HTML. , : window,
document. write(cipoKa).
!
window j
window
<HTML>
<1> -</1>
</HTML>
document
<HTML>
<1> 11-</1>
<IMG SRC = "pict.jpg">
</HTML>
<HTML>
<1> -</1>
<IMG SRC = "pict.jpg">
<FORM>
</FORM>
</HTML>
<HTML>
<1> -</1>
<IMG SRC = "pict.jpg">
<FORM>
<INPUT TYPE = "text" VALUE = "
<BUTTON> <BUTTON>
</FORM>
</HTML>
window _J
)
I winword )
document
)
images
forms
text
button
. 2.. HTML-
126
2.
, , HTML- . ,
, . , window.
, , location
URL- screen
. document,
window. ,
HTML-, , ( , , ) . . 2.3
, . , , ,
.
. HTML
.
. ,
. , , HTML-. . ,
. length
. , ,
images, forms, links. .
, all.
(, images),
all.
all .
. , .
. ,
, , window ,
document. :
document.iwieKL(Mfl.id_o6beKTa;
id_o6betaa ID , HTML- . _ , .
0. HTML- ID
, .
, (, <FORM>, <IN PUT>) NAME.
ID. , , NAME ( ),
<FORM>, ID:
2.3. ,
127
document._
, <FORM>
, <INPUT>, <BUTTON> .
all.
:
document._.elements[_]
document._.elements[id_3neM6HTa]
document._. _
_ ,
; 0. , Internet
Explorer .
HTML- -,
, , .
<HTML>
<1> -</1>
<IMG SRC = "pict.]pg">
< HREF = "www. admi ral. ru/~dunaev">CaUT </>
<FORM>
INPUT TYPE = "text" VALUE = "">
<p>
<BUTTON onclick = " ( ) " > < / >
</FORM>
</HTML>
. 2.4 -
. ID
( NAME), . , , ( )
document.images(0)
/ / i m a g e s
. , (
forms(O)), (15(_)). , :
document.forms(0).elements(l)
/ /
.
links. links .
, links(O) links. HTML- :
document.links(0)
, , all.
.
ID HTML-,
, all , , . , .
, HTML-.
, . , -
128
2.
Web-
<HTML>
<1> -</1>
IMG SRC='pictjpg'>
HREF = 'www.admiral.ru/~dunaev'>CaiiT </>
<FORM>
<INPUTTYPE = 'text1 VALUE = ">
<p>
<1> <01>
</FORM>
</HTML>
document
is(0)
images(O)
^
-->
link:
. 2.4. -
all document?
,
HTML-. t a g N a m e , ,
. 2.1.
2.1. HTML-
<HTML>
<1> -</1>
<>
<IMG SRC = "pict.jpg">
<>
< HREF = "www. admi ral . ru/~dunaev">CauT </>
<p>
<FORM>
<INPUT TYPE = "text" VALUE = "">
<p>
<BUTTON onclick = "()"> </>
</FORM>
<SCRIPT>
msg = ""
for(i = 0; i < document . all . length; i++){
msg += i + " " + document . all [i ]. tagName + "\n"
alert (msg)
129
2.3. ,
</SCRIPT>
</HTML>
Web-
Microsoft Internet Exploie
,v
"V
0 HTML
1HEAO
2 TITLE
/FORM
8IWPIJT
3P
10 BUTTON
11 SCRIPT
'
:...;., .;...; ;;.v...1:..'1.
.'$
, ID,
.
, HTML- , . , ,
ID (. 2.6).
ID, id . HTML 2.2.
2.2. ID
<HTML>
<1> -</1>
<IMG ID = "myimage" SRC = "pict.jpg">
130
2.
2.2 ()
<SCRIPT>
msg = " "
for(i =0; i<document.all.length; i
msg+= i + " " + d o c u m e n t . a l l [ i ] . t a g N a m e + " id = "+ document .all[1].id
+ "\n"
}
alert(msg)
</SCRIPT>
</HTML>
|
!
Web-
Microsoft Internet Explore!
HTML id11*
!
7 FORM id =
SIN PUT i,j
|qewe
I
:::::;::-
2.4.
131
,
<IMG ID = "myimage" SRC = "pict.jpg">, ID SRC. id src . :
document.images(0).id
// "myimage"
document.images("my i m a g e " ) . i d
document.all("my i m a g e " ) . i d
document.all.my image.id
var x = document.all.myimage
//
x.id
// "myimage"
document.images(Q) . src
/* U R L , ,
f :///:/%20/^. jpg */
document.images("myimage") .src
document.all("my image").src
document.all.myimage.src
var x = document.all.myimage
//
x.src
/* URL, ,
f i l e : / / / : / % 2 0 / 1 c t . j p g */
.
- . ,
(, src). ,
.
2.4.
( ,
. .) , . (, Windows) , , . , ,
, , Windows , , ,
. - ,
. HTML-, . HTML-
. .
2.4.1.
, . , . , , , , ,
. ,
, (, , , . .).
132
2.
, . ,
, . , ( ).
. , .
event,
window. , , , . event
, -. event.
HTML-,
. event (. 2.7). , , . keyCode
Unicode.
Unicode ASCII . keyCode null.
, keyCode , . onkeydown onkeyup, on keypress.
"UMr.JMhl.Mri-!.
_J
1
. 2.7.
<HTML>
<BODY ID = "test">
</BODY>
<SCRIPT>
2.4.
133
1
?
4
5
6
7
srcElement HTML-, . .
HTML- ,
(. 2.8). onclick . , <BODY>. , (. 2.9). onclick
( changetextQ),
<BODY>. , , . ,
srcElement, innerText. . , ,
.
<HTML>
<BODY onclick = "changetext()">
<button>nepsa KHonKa</button>
<11> KHonKa</button>
</BODY>
2.
134
<SCRIPT>
function changetextO {
= window.event.srcElement
x.innerText = " '
//
//
</SCRIPT>
</HTML>
\1. - Micro... 1
gie
...... .
.. . -
""
Cr
["" *. -" .]
. 2.8.
:\ \811{. - Micio... |
.
Ij.u
~". --^
"^ -
'-'
--^ '
. 2.9.
, :
<1_>
<BODY>
<button onclick = "changetextO "> KHonKa</button>
<button onclick = "changetextO"> KHonKa</button>
</BODY>
<SCRIPT>
function changetextO {
x = window.event.srcElement
x.innerText = " "
I
</SCRIPT>
</HTML>
//
//
2.4.
135
event , , . . .
screenX, screenY
. , 800x600,
800 600 .
clientX, clientY
( ), HTML-,
, , . .
offsetX, offsetY
, .
,
, , .
, - (, <BODY>,
<DIV>, <H1>) STYLE, position.
, , , clientX, clientY.
, HTML-,
, ,
(. 2.10). ,
<DIV>. , , , .
.
**
J1
.11
!\
PHI
;
ofkctX-234. oft>etY80 - ' " : .
i
l
l
. 2.10.
136
_ 2.
<HTML>
<BODY ID = "Mybody"
<DIV ID = "DIV1" STYLE = "posi ti on : absolute ; left: 50; top:50; width:300;
h e i g h t : 100; background -co lor :blue">
<DIV ID = "DIV1" STYLE = "posi t i on : relati ve ; left:50; top:25; width:200;
<BODY>
<SCRIPT>
function document. onclickO {
, ,
, - document.
onclick().
srcElement id , (, , ) .
event returnValue ( ). , .
false. ,
.
.
<HTML>
< ID = " m y r e f " HREF = " w w w . chat . "> c h a t . r u < / A >
<SCRIPT>
confirm() .
, confirm () false, returnValue
false. .
, ,
( ), ,
. .
returnValue:
2.4.
137
<HTML>
< ID = "myref" HREF = ""> </>
<SCRIPT>
function myref.onclick(){
alert("5bm ")
window.event.returnValue = false
}
</SCRIPT>
</HTML>
window.event.returnValue = false, - H R E F .
, ,
, HREF "#", :
< ID = " m y r e f " HREF = "#" o n c l i c k = " m y c l i c k ( ) " > < / >
2.4.2.
, ,
, . ,
, myfunc(), : onclick =
"myfuncO". , HTML , , . , ,
. ?
?
HTML-, :
<1_>
138
2.
.
onclick . NN4 .
, ,
window .
, . captureEventQ. IE4
cancelBubble.
IE5.5+ NN6 ,
, . IE4+,
NN4. ,
. , .
IE4+ cancelBubble
event. ( -) , event ,
. , event onclick
( ), ,
. ( ), z-, . , z-index
. , , event
. ,
(ID) Myelement, Myelement.onclickQ. event , . , . , , , <DIV> Mydiv,
Mydiv.ondickQ. ,
. ,
( document), event
document.onclickQ.
(, ), srcElement. . ,
,
. ,
, -. cancelBubble true, . ,
Myelement, -
:
function Myelement . o n c l i c k Q {
// onclick
w i n d o w . e v e n t . c a n c e l B u b b l e = true
}
- document , ,
- ( ) .
2.4.
139
HTML-
, <BODY>:
<HTML>
<BODY onclick = "alert(' body')">
<BUTTON onclick = "alert(' button')"> </>
</BODY>
</HTML>
, , , (,
<BODY>. , :
<1_>
<BODY onclick = "alert(' body')">
<BUTTON onclick = "alert(' button');
window.event .cancelBubble = true "> </11>
</BODY>
</HTML>
:
<1_>
<BODY onclick = "alert(' body')">
<BUTTON ID = "> </1>
</BODY>
<SCRIPT>
function Mybut.onclick(){
1
alert(' b u t t o n )
window.event.cancelBubble = true
//
</SCRIPT>
</HTML>
2.4.3.
.
HTML- ID - FOR EVENT. - , , ,
. - .
, .
<HTML>
<BUTTON ID="Mybutton" onclick="butclick()"> </>
<SCRIPT>
document .all .Mybutton. onclickO
//
function butclick(){
alert(' Mybutton')
</SCRIPT>
</HTML>
onclick, .
butclick(). , ,
140
2.
. , (
onctickQ) .
, .
, , , onfocus ( ). ,
. onfocus.
, onfocus
, :
document. _. _ .onfocusO
, , :
<HTML>
function onload(){
>
</SCRIPT>
</HTML>
2.5.
, HTML- . ,
, .
. ,
.
HTML- ,
, window.
:
window.
wi n d o w . [ ] )
141
2.5.
IE NN. IE navigateQ:
window, navi 1("1*1--_")
2.5.1.
, ,
, URL- . HTML
TARGET < H R E F = .. .>. , < HREF
= "http://www.rambler.ru" TARGET = "newWindow"> Rumbler</A>.
. ():
window.open([])
:
, ;
( );
(features).
=,
. . 2.2 ,
features. yes
1 0 .
2.2. , features
channel mode
yes, no, l, 0
Channel
directories
yes, no, 1, 0
fullscreen
yes, no, 1, 0
height
left
location
yes, no, 1, 0
Address
menubar
yes, no, 1, 0
resizeable
yes, no, 1, 0
scrollbars
yes, no, 1, 0
status
yes, no, 1, 0
&
142
2.
2.2 ()
toolbar
yes, no, \, 0
top
width
143
2.5.
2.3. , showModalDialogQ
order
thick, thin
(/)
center
yes, no (1, 0)
dialogHeight
dilalogLeft
dialogTop
dialogWidth
font
font-family
,
,
,
font-size
font-style
font-variant
(/),
font-weight
help
yes, no, 1,
Help
maximize
yes, no, 1, 0
Maximize
minimize
yes, no, 1, 0
Minimize
<1_>
var newWindow
//
function OpenWinl(){
// 1-
window. status = " "
//
strfeatures = " top=100 , let t=50,width=300 , heigh t=270 , toolbar=no"
window. open ("1. htm ","winl",strfeatures)
}
function OpenWin2(){
// 2-
window. status = " " //
strfeatures = "di alogWidth=500px;di alogHeight=320px , border=thin ; help=no"
window.showModalDialog("2 . htm" , "win2" , strfeatures)
function CloseWinl(){
if (newWindow) {
newWindow .close()
// 1-
// 1-
// 1-
144
2.
newWindow = null
window.status = ""
// 1-
}
;
</SCRIPT>
</HTML>
2.5.2.
, HTML-.
HTML-, HTML-, . ,
, , . , <>.
, .
, <FRAMESET>. <FRAME>
, HTML-, . ,
:
<HTML>
<FRAMESET ROWS="30%,70%"
.
ROWS <FRAMESET> COLS, : . <FRAMESET>, . .
, ,
, ,
, , -.
. , - (-).
w i n d o w .
,
. , <FRAM E> <FRAM ESET> window, . document.
145
2.5.
d o c u m e n t . , .
. 2.11.
, window.
, framel frame2. window f r a m e l frame2 (. 2.11). parent.
, ,
, .
:
-;
- () ;
- -.
frame2
. 2.12.
. ,
, -
2,
146
.
. parent (. 2.13). ,
location (, location): location.href
URL-. , , :
parent.location.href="1-_"
parent /
. 2.13. parent
, - (. 2.14). , , - -.
- .
frarne2 , framel. framel
frarneZ, frame2 .
, frame2,
document, :
p a r e n t . f r a m e 2 . d o c u m e n t . w r i 1 ( " ! ")
. 2.14. -
, . .
2.5.
147
HTML- , (. 2.15).
LEFT:
<HTML>
<1?>
<1 ID = ""></1>
</HTML>
:
<1_>
<5CRIPT>
function changeQ {
parent.LEFT.document.all.XXX.innerText = "!"
}
</SCRIPT>
<H1 onclick = "changeO "> </1>
</HTML>
- : . , v:-
. .: V .,,:<:..:<:
:::*:
. 2.15.
148 _
2.
. : , .
frames.htm - .
<HTML>
<FRAMESET COLS = "25%,75%">
<FRAME SRC = "menu. htm" NAME = "menu">
<FRAME SRC = "start.htm" NAME = "main">
</FRAMESET>
</HTML>
start.htm , main.
menu.htm - .
<HTML>
<SCRIPT >
function load (url) {
parent .main . location . href = u r l ;
}
</SCRIPT>
<BODY>>
<
<A HREF = "javascript : load( ' . htm ') "></
</>
<A HREF = ". htm" TARGET = "mai "> </>
<A HREF = ". htm" TARGET = '"> </>
</BODY>
</HTML>
main. load(). TARGET
. loadQ '. htm', , . ,
, load(). TARGET. ,
. loadQ, :
parent . location . href = url
TARGET < HREF> ,
. ,
, .
frames . .
, NAME FRAME:
window. frames []
window. _
, 0 , <FRAME> <FRAMESET>.
, .
2.5.
149
, , , ,
document.
w i n d o w . f r a m e s ( 0 ) . d o c u m e n t . a l l . M y input.value
w i n d o w . L E F T . d o c u m e n t . a l l . M y input.value
parent.
, : parent.parent. . , , top.
top ,
. top
, , , . parent
().
top self
. , , .
(top) (parent) . , top self . , . , , .
:
<SCRIPT>
if (top != self)
top.location = location
</SCRIPT>
( ) ,
. . . , .
, -
, URL- top .
, ,
frameset.htm.
<SCRIPT>
if (top.location.href == window.location.href)
top.location.href = "frameset.htm"
</SCRIPT>
150
2.
2.5.3.
HTML- , , <IFRAME>:
<IFRAME SRC = "_"></1>
, , (<5!> STYLE). , <IFRAME> HTML. (
), HTML. .
HTML-, ,
, HTML-.
HTML- (. 2.16).
HTML- (www.admiral.ru/-dunaev).
<HTML >
<> HTML- </>
<4> < iframe></H4>
<>
<IFRAME SRC = "examples.htm" ></IFRAME>
<IFRAME SRC = "flashx.htm" ></ IFRAME >
<p>
<IFRAME SRC = "i_is.htm" STYLE = "position: absolute; top:310; width:500;
height:250" SCROLLING = no" ></IFRAME >
</HTML >
4.2.2
( 4).
, . , frames. align . :
absbottom ;
absmiddle top
absbottom ;
baseline ;
bottom baseline ( IE);
left -;
middle ;
right -;
texttop ;
top .
151
2.5.
-3 HTML- - Microsoft Internet Explo
.
i-;i3 1
,,
HTML-
< iframe>
Flash- Web
Flash-
''- (..
swf,
"*'*'*'''"'
'
: ".
^ mew Web-.
.; - '--
: , -, *,8!
&
/.
), Flash, ,
j
1
........
. 2.16. ,
2.5.4.
, , .
-
. Windows. .
, ,
.
.
152
2.
.1
. J ^
'
I G)
']
' ...
^Adobe Photoshop ..
I ListSoft
| 4 MSN.com
I <|
,.^: . f.1
. 2.17.
popup:
document , , ;
, :
mypopup.document .body . s t y l e . b o r d e r = "solid 4px b l a c k "
//
mypopup.document.body . s t y l e . b a c k g r o u n d = " y e l l o w "
//
mypopup.document .body . s t y l e . c o l o r = "blue"
//
isOpen ,
true, false; , .
popup:
show(left, top, width, height [, ])
popup window.createPopupQ
2.5.
153
. - , - ,
show(). . left top ,
. HTML-. , document.body,
.
hideQ .
innerHTML, , HTML.
2.6.3. , , .
function pop(xcontent){
var mypopup = window.createPopup();
var popupBody = mypopup.document.body
popupBody.style.border = "solid 2px green"
popupBody.style.padding = "5px"
popupBody.style.color = "blue"
popupBody.style.background = "ffffdO"
p o p u p B o d y . i n n e r H T M L = "<p>" + xcontent + "</p>"
mypopup.show(130,90,400,200,document.body)
I
</SCRIPT>
</HTML>
()
, . , , ():
<HTML>
<> </>
154
2.
Mj&tjdHHUV
Cu
,
I :(>IM:I
; .
'.
L.'J
. 2.18.
2.6.
HTML-, , . , , . :
writeQ;
2.6.
155
, HTML- ;
innerText, outerText, innerHTML, outerHTML,
, .
2.6.1. writeQ
writeQ document .
, HTML- /
. document.write(cTpoKa) HTML- .
. HTML- . , document.dearQ, document.write(cTpoKa).
.
HTML- , HTML- .
, , writeQ
:
document.writeCcrpOKal, [, 2 . . .[, ] ] )
. , . , HTML-
.
writeQ writelnQ, . , .
writeQ writelnQ IE3+ NN2+.
2.6.2.
HTML-, , , (). , . ,
.
. . : , , . , <IMG ID = "myimg" SRC = "picture.jpg">
document.all.myimg, SRC document.allmyimg.src,
(URL-) . , HTML- .
156
2.
, STYLE. , HTML-:
<IMG ID = "myimg" SRC = " p i c t u r e . j p g "
STYLE = "position:absolute; top:20; left: 50: z-index:3">
,
style:
document.all.myimg.style.top = 30
document.all.myimg.style.top = 100
document.all.myimg.style.zlndex = -2
z-index , ( -) ,
zlndex.
HTML , , , , , .
!
4, 4.1.
2.6.3.
HTML-
IE4+ innerText, outerText, innerHTML outerHTML
NN6+ innerHTML
4, .
/ .
.
, , . , , Flash-.
innerText ,
.
HTML-, . ,
innerText . , innerText ,
.
outerText innerText, ,
,
. , outerText , , .
HTML-,
, :
2.6.
157
<DIV ID = "my">
< HREF = ' raznoe . htm' > 1
<IMG SRC = ' picture. jpg > <></>
innerText outerText , <DIV>, :
document . all . my . innerText
// : "
"
innerText outerText
, HTML-, , . , HTML
d o c u m e n t . a l l . my . i n n e r T e x t = "<> </11>"
, , .
innerText outerText , innerHTML outerHTML.
HTML JavaScript.
innerHTML , HTML-,
. , innerHTML HTML-
. , HTML-,
. , .
outerHTML innerHTML, , HTML-, .
HTML- :
document . all .my . i nnerHTML
/* :
"<A HREF = ' raznoe.htm' >
<IMG SRC = ' picture. jpg' >
<></></>" */
document . all .my . outerHTML
/* :
"<DIV ID = 'my ' >
<A HREF = ' raznoe.htm 1 >
<IMG SRC = ' picture. j p g ' >
<></>
< / A > < / D I V > " */
, , :
d o c u m e n t . a l l . m y . i n n e r H T M L = "<> </1>" ,
, .
<DIV ID = "my"> .
innerHTML outerHTML, ,
<DIV ID = "my">.
, i n n e r H T M L outerHTML ,
, <IMG>. innerHTML outerHTML .
158
2.
getproperties (xid),
innerHTML, outerHTML, innerText outerText HTML-.
ID ( NAME) .
.
function getproperti es (xid) {
var x = eval ( "document . all ." + xid)
a l e r t ( " innerHTML: " + x . innerHTML + "\n outerHTML: " + x . outerHTML +
"\n innerText: " + x . innerText + " \ n o u t e r T e x t : " + x . o u t e r T e x t )
}
getproperties(xid):
<HTML>
<DIV ID = "my">
<A HREF = ' raznoe.htm' >
<IMG SRC = ' picture . jpg ' > <></></>
<2 ID = "privet">ripHBeT <1></1></
<SCRIPT>
getpropertiesC'my")
// my
getproperties ("privet ")
//
privet
function getproperties("xid"){
//
}
</SCRIPT>
</HTML>
2.7.
- , , : , , , , . . / ,
. . , .
, .
<IMG> SRC LOWSRC, , , ,
. , JavaScript.
- , .
. , , ,
. .
2.7.
159
. , <IMG>. , ,
. .
,
:
myimg = new 1(, )
-
WIDTH HEIGHT <IMG>, .
m y i m g , , URL- . src:
myimg. src = "111_-_"
- , . -
. src <IMG> -. :
document.images[0] . src = myimg.src
src
, <IMG>, src -.
HTML-,
(. 2.19). .
- . , , <SELECT>, <OPTION>. HTML- . 2.3
.
2.3. HTML-,
<HTML>
<HEAD>
<SCRIPT>
//
var i m g F i l e = new ArrayO
imgFile[0]
imgFiletl]
imgFile[2]
imgFile[3]
=
=
=
=
"pictl.jpg"
"pict2.jpg"
"pict3.jpg"
"pict4.jpg"
//
//
160
2.
imgName[3] = "4"
/* */
//
var imgObj = new A r r a y O
for(i = 0; i < imgFi le. "length ; i//
imgObj[i] = new Image(150, 100)
/*
imgObj[i].src = imgFile [i]
*/
i
/*
var = li st .options [li st . selectedlndex] . value
/*
*/
document .all. imgO. src = eval ("imgObj [ "+ x + "].src")
I
/* */
var clist = "<SELECT onchange= ' imgshow(thi s) ' >"
for(i = 0; i<imgFile. length; i++){
clist+= "<OPTION VALUE=" + i + ">" + imgName[i]
clist+= "</5ELECT>"
document .wri te(cli st)
/*
*/
</SCRIPT>
</HEAD>
<! >
<IMG ID = "img0" SRC = "pict0.jpg" WIDTH=150 HEIGHT=100>
</HTML>
10AKHMraJavaSCrip.\pmba\imgtoad.hto M m..'
3;1
1
. 2.19.
, evalQ. HTML-, , :
2.8.
161
2.8.
, , (, ) JavaScript. () . , , .
. - ,
.
.
( ) setlntervalQ
window. :
setlnterval(, [, ])
, ( , ). ,
, . , ,
; JavaScript. setlntervalQ
, , (. clearlnterval()).
, , , myfuncQ 0,5 . :
setlnterval("myfunc()", 500)
, setlntervalQ ,
. ,
, ,
, , setlntervalQ. ,
setlntervalQ , paraml param2, :
v a n x s t r = " m y f u n c ( " + paraml + " , " + param2 + " ) "
s e t l n t e r v a l ( x s t r , 500)
, setlntervalQ,
. , ,
- ,
.
162
2.
clear!nterval(MfleH), , setlntervalQ, :
var myproc = setlnterval("myfunc(), 100")
if (confirm(" ?"))
clear Interval (myproc)
, setlntervalQ clearIntervalQ 4.1 4.2.
,
setTimeoutQ. window :
setTimeout(, [, ])
, ( , ). ,
, . , ,
; JavaScript. setTimeout() ,
, (. clearTimeoutQ).
, , , myfuncQ 1 . :
s e t T i m e o u t ( " m y f u n c ( ) " , 1000)
,
. myfuncQ.
var myproc
function start.onclickO{
myproc = setTimeout("window.open('mypage.htm')", 5000)
}
function stop.onclickO{
clearTimeout(myproc)
</SCRIPT>
</HTML>
2.9. Cookie
163
setTimeoutQ
4.8.10.
setlntervalQ setTimeout() , .
2.9. Cookie
cookie. , -, .
,
. , . ()
, , -
, New !.
,
. : , , ,
; , .
, cookie
, . , - (. 5). , cookie-
.
cookie Internet Explorer , Windows\Cookies. , cookie. Netscape Navigator 4 Windows cookie.txt.
, cookie-
, , -, , -, IE NN cookie-, document.cookie.
, cookie- . , :
;
;
() ;
, ;
http- ;
164
2.
, .
( _-),
, ,
.
, cookie-. , IE4+ NN4+ cookie- 20 .
cookie- JavaScript
, cookie-, document.cookie.
:
document.cookie = "!<1=
[; expi5=__]
[; path=nyTb]
[; domai =]
[; secure]"
, ( ).
cookie-.
-. cookie- ,
. ,
cookie- User_Name, JavaScript :
document.cookie = "User_Name=Bacfl"
cookie- . , . , . cookie-
, .
(%20), escapeQ.
. () cookie-
(GMT). ,
:
var expdate = new Date()
//
var inonthFromNow = expdate . getTime () + (30*24*60*60*1000)
expdate.setTime(monthFromNow)
//
GMT:
document.cookie = "User_Name=BacH; expires=" + expdate.toGMTString()
Cookie- , , :
e x p d a t e = T h u . 0 1 - J a n - 7 0 00:00:01
2.9. Cookie
165
, cookie-
.
. 1.7.5.
path cookie-, , ,
( ).
cookie , .
d o m a i n cookie-
cookie- , .
cookie-,
document.cookie, -, cookie- . , rambler.ru.
secure (true false). cookie ( ) .
cookie. cookie, JavaScript, document.cookie. () cookie
String (. 1.7.1). ,
cookie- ( 20) , JavaScript
^
.
readCookie(name), cookie-, name, :
function readCookie(name) {
// cookie-
var xname = name + "="
var xlen = xname.length
var den = document.cookie.length
var i =
166
2.
, , (%20).
:
function getCookieVal (n) {
/* ,
readCookieQ */
var endstr = document . cookie . indexOf( " ; " , n)
if (endstr == -1)
endstr = document .cookie. length
return unescape(document . cookie . substri ng(n , endstr))
}
writeCookieQ,
cookie-:
function wri teCookie (name, value, e x p i r e s , path, domain, secure) {
/* cookie */
document .cookie =
name + "=" + escape(value) +
((expires) ? "; expires=" + expi res . toGHTStringO : " " ) +
((path) ? " ; path=" + path : " " ) +
((domain) ? " ; domain=" + domain : " " ) +
((secure) ? "; secure" : " " )
}
:
name , cookie- ( );
value , cookie ( );
expires (Date), cookie-;
, cookie- ;
path , cookie-; , ;
d o m a i n , cookie-; ,
;
secure (true false),
HTTP-.
, writeCookieQ
value escapeQ.
cookie- :
function deleteCookie(name , path, domain) {
/* cookie- */
if (readCookie(name) ) {
document .cookie =
name + "=" +
((path) ? "; path=" + path : "") +
((domain) ? "; domain="+domain : "") +
"; expires=Thu, 01-Jan-70 00:00:01 GMT"
cookie- ,
. path , cookie-, (null),
2.9.
Cookie
167
. domain.
, cookie ( 2.4). , cookie- .
( ). , cookie-
document. cookie .
2.4. HTML- , cookie-
<HTML>
<SCRIPT>
function readCookie(name) {
...
}
function getCooki eVal (n) {
. . .
I
// cookie-
//
/* ,
readCookieO */
//
/* cookie: */
wri teCookie( "my record"," ", dl)
alert (readCookie( "my record") )
</SCRIPT>
</HTML>
, .
cookie-
(, myspecrecord) , .
,
. cookie- , .
, cookie- myspecrecord .
, . ,
cookie-. , ,
, cookie- . ,
, (,
).
168
2,
,
cookie- .
. 4, 4.8.10.
, cookie- , - . , Date (. 1.7.5).
3.
(. 3.1).
- . 4, . ,
, .
3.1. window
window frames , HTML- <FRAMESET>. window , , , .
, , .
3.1.1. window
parent ;
self ;
top ;
name ;
opener , ;
closed , ;
status , ;
defaultStatus ;
returnValue
;
client , ;
document document;
event event;
history history;
170
3.
frames
(window)
. 3.1.
location Location;
navigator navigator;
screen screen.
parent ,
, , , .
parent.parent . .:
3.1. window
171
parent, window.frames(0)
parent.parent.window.frames(0)
, , top. top .
name , <FRAMESET>.
status
, :
window.511=" "
3.1.2. window
() ;
close() ;
showHelpQ ;
showModalDialog() ();
alertQ ;
promptQ ,
Cancel ();
confirmQ Cancel
();
navigateQ ;
blurQ ; onblur;
focus () ; onfocus;
scrollQ ;
setlntervalQ ;
setTimeoutQ
;
clearlntervalQ , setlntervalQ;
clearTimeoutQ , setTimeout();
execScriptQ ; JScript.
3.1.3. window
o n b l u r ;
onfocus ;
onhelp F1;
onresize ;
onscroll ;
onerror ;
3.
172
o n b e f o r e u n l o a d , ;
onload ;
onunload .
. ,
, .
o n b l u r onfocus. , , blur focus. , onerror.
, , , - .
<SCRIPT>
function window.onerror(){
alert(" ! ")
</SCRIPT>
onload , ;
onbeforunload ; onunload , .
<SCRIPT>
function window.onunload(){
alert(" !")
</SCRIPT>
window , : document, history, navigator, location, event screen.
3.2. document
d o c u m e n t
HTML-
. . , .
3.2.1. document
activeElement
alinkColor
bgColor
body
A LIN
BGCOLOR
, <BODY>
173
3.2. document
cookie
cookie-.
cookie
domain
fgColor
TEXT
LINK
lastModified
linkColor
location
parentWindow
URL
readyState
referer
URL ,
selection
document selection
title
TITLE
url
URL
vlinkColor
VLINK
URL- <>
3.2.2. document
all ;
anchors () ;
applets , , , , ;
embeds ;
forms ;
frames , <FRAMESET>;
images () ;
links <AREA> ;
plugins ;
scripts <SCRIPT> ;
stylesheets , .
3.2.3. document
clear ;
close ;
174
3.
createElement ;
elementFromPoint ;
execCornmand () ;
open
write writein;
queryCommandEnabled , ;
queryCommandlndeterm , ;
queryCommandState ;
queryCommandSupported , ;
queryCommandText , ;
q u e r y C o m m a n d V a l u e , TextRange;
write HTML ,
;
writein HTML, .
3.2.4. document
onafterupdate ;
onbeforeupdate ;
onclick ;
ondblclick ;
ondragstart , ;
onerror ;
onhelp F1;
onkeydown ;
on keypress
;
onkeyup , ;
onload ;
onmousedown ;
omousemove ;
o n m o u s e o u t , ;
onmouseover , ;
onmouseup , ;
onreadystatechange readystate;
onselectstart , .
3.4. history
175
3.3. location
location URL- ( ) , , .
3.3.1. location
href URL- ;
hash , URL #, , .;
host URL .; ,
URL-;
hostname URL ;
pathname , /;
port URL;
protocol , , , http:;
search URL ?.
, http://www.piter.com, location.href .
href ,
, :
window.location.href = "http://www.rambler.ru"
3.3.2. location
assign() ;
window.location.href;
reloadQ ;
replaceQ URL- URL- (location.href).
- ,
. , , . , (Back).
location.replace(URL-aflpec) , .
3.4. history
history , . -
176
3.
. history
.
3.4.1. history
length .
, .
3.4.2. history
back() ;
forwardQ ;
() ( 0
history.length-1) URL-.
,
, ,
:
.window.history.go(l)
if (window.hi story.1ength>4)
window.hi story.go(5)
, history.go(-l) history.backQ, window.history.
go(l) history.forwardQ.
3.5. navigator
navigator ,
.
3.5.1. navigator
appCodeName ; "Mozilla";
appName ; "Microsoft Internet Explorer";
appVersion ; "4.0 (compatible; MSIE 6.0; Windows 98;
Win 9x4.90)";
cookieEnabled cookies
; ;
userAgent , http-; "Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; Win 9x 4.90)".
3.5.2. navigator
mimeTypes ,
;
plugins .
3.6. event
177
3.5.3. navigator
taintEnabled false, Netscape
Navigator;
javaEnabled ,
JavaScript; .
3.6. event
event - , . :
altKey Alt, ;
button , ;
cancelBubble
;
clientX , , ,
. .;
clientY , , ,
. .;
CtrlKey Ctrl ;
from Element , , onmouseover onmouseout;
keyCode ASCII ; ,
;
offsetX
;
offsetY
;
reason , -
;
returnValue ;
screenX , ;
screenY , ;
shiftKey Shift ;
srcElement , ;
srcFilter , onfilterchange;
toElement , , onmouseover onmouseout;
type , on;
178
3.
, ;
, .
event ( ).
: keyCode return Value. event.
3.7. screen
screen , , ( 32- , 256 ).
screen :
width ( );
height ( );
bufferDepth , ;
colorDepth , ,
; ;
updatelnterval .
3.7.1. TextRange
TextRange ( ) , HTML-. .
3.7.2. TextRange
htmlText TextRange HTML;
text , TextRange <>.
3.7.3. TextRange
collapse
;
compareEndPoints ,
;
3.7. screen
179
duplicate TextRange;
execCommand () ;
expand , , , , , ;
findText , ;
getBookmark , ;
i n R a n g e , ;
i s E q u a l , ;
move ;
moveEnd ;
moveStart ;
moveToBookmark , getBookmark;
moveToElementText
;
moveToPoint
;
parentElement , ,
;
pasteHTML / HTML- ;
queryCommandEnabled , ;
queryCommandlndeterm , ;
queryCommandState ;
queryCommandSupported , ;
queryCommandText , ;
queryCommandValue , TextRange;
scrollIntoView
;
select ;
setEndPoint
.
4.
.
, , -, . , .
4.1.
4.1.1.
- . . .
, SRC <IMG>. , SRC , .
<IMG>, , HTML-, src.
. , , , . pictl.gif pict2.gif. , ,
onclick <IMG>.
<HTML>
4.1.
181
<[_>
/*
*/
/*
*/
182
4.
4.1 ()
else
document.all[xid].src = apict2[n]
aflag[n] = !aflag[n]
/*
*/
</SCRIPT>
</HTML>
, src: document.allfxid].src,
document.all.xid.src document.all["xid"].src. ,
xid , ID, .
4.1.2.
.
.
.
. , , <FORM>.
o n m o u s e o v e r ( ) o n m o u s e o u t (
). , ()
( ).
, 16- . (yellow) (. 4.1).
<1_>
<STYLE>
mystyle {font-weight:bold ; background-color:aOaOaQ}
</STYLE>
=
=
=
</SCRIPT>
</HTML>
183
4.1.
IJDAKHiiraJavaSci
fin
'.] [ ]
'[.
. 4.1.
, <>,
:
<HTML>
< onmouseove r= "colorch('red ')" onmouseout = "colorch('blue ')"
style="color: "> </>
<SCRIPT>
function colorch(color){
event.srcElement.style.color = color
}
</SCRIPT>
</HTML>
4.1.3.
, , . . .
, ,
setlntervalQ. , , . 2.8.
0,5 (. 4.2):
<HTML>
<TABLE ID="mytab BORDER=1 WIDTH=150 style="border:10 solid:yellow">
<TR><TD>Mnraiom.afl paMKa</TD></TR>
</TABLE>
<SCRIPT>
,
function flash() :
if ((document.all)
return null;
if (mytab.style.borderColor == 'yellow')
4.
184
raytab. style. borderColor = 'red'
else
mytab. style. borderColor = 'yellow';
setlnterval("f lash() " , 500);
</SCRIPT>
</HTML>
// 500
. 4.2.
4.1.4.
-
. , .
,
. 4.2 , , . .
4.2.
<HTML>
< HREF="http: / / w w w . admi ral. ru/~dunaev/i_i s . "></>
<A HREF=" http: / / w w w . admi ral. ru/~dunaev/examples . 1_"> HTML
JavaScript</A>
<A HREF=" h t t p : / / w w w . a d m i r a l . r u / ~ d u n a e v / m y b o o k . h t m " > M o H </>
<SCRIPT>
aclrlink=new A r r a y O
//
//
aclrlink [ 0 ] = ' y e l l o w '
aclrlink [1]='#80FF80'
aclrlink [ 2 ] = ' # F F F F 8 0 '
aclrlink [ 3 ] = ' # 4 0 8 0 0 0 '
aclrvlink k=new A r r a y O
//
aclrvlink [ 0 ] = ' b l u e '
aclrvlink [1)='purple'
aclrvlink [ 2 ] = ' b l a c k '
aclrvlink [ 3 ] = ' r e d [
4.1.
185
function colorchangeO {
//
link=Math. round((aclrlink.length+0. l)*Math. randomO)
vlink= M a t h , round ( ( a c l r v l i n k . l e n g t h + 0 . l)*Math. randomO)
document.linkColor= aclrlink [link]
document.vlinkColor= aclrvlink [vlink]
}
setlnterval("colorchange()",500)
</SCRIPT>
</HTML>
// 500
, HTML-
,
HnkColor vlinkColor document.
4.1.5.
() -.
, HTML-
<IMG>.
, .
:
. . ( ),
. - . ( ) .
.
4.3 HTML-, (. 4.3).
<>. . STYLE <DIV>,
.
4.3.
<1_>
< H E A D > < T I T L E > 3 d </TITLE><HEAD>
<! >
<STYLE>
{font-family:sans-serif; f o n t - s i z e : 7 2 ; font-weight:800;
color:00aaaa}
P.highlight { c o l o r : s i I v e r }
P . s h a d o w {color i d a r k r e d }
</STYLE>
<BODY BGCOLOR = aeb98c>
<! >
<DIV S T Y L E = " p o s i t i o n : a b s o l u t e ; t o p : 5 ; l e f t : 5 " >
<P C L A S S = shadow>0e < / >
4.
186
4.3 (]
<\ >
<DIV STYLE = "position:absolute; top:0; left:0">
<P CLASS = highlight>06beMHbiu </>
<! >
<DIV STYLE = "position:absolute; top:2; left:2">
<> </>
</BODY>
</HTML>
j 3d - Microsoft Internet Explomr
'
\ 1.0
. 4.3. ,
, ( 4.4).
4.4. ,
function d 3 ( t e x t , , , tcolor, f s i z e , f w e i g h t , f f a m i l y , zind) {
/*
:
if
/*
if
if
if
if
if
text -
- (left)
- (top)
tcolor -
fsize - ()
fweight - ( )
family -
zind - z-Index
*/
(Itext) return null /* , */
:
*/
(Iffamily) ffamily='arial'
(Ifweight) fweight=800
(Ifsize) fsize=36
(Itcolor) tcolor='00aaff'
(!y) =0
4.1.
187
if (!x) =0
/* */
var sd=5 , hd=2
//
var xzind=""
if (zind) xzind=" ;z-Index: "+zind
var xstyle=' f ont-f ami ly : ' + family + '; font-si ze: ' + fsize +
'; font-weight :' + fweight+';'
var xstr = '<DIV STYLE = "posi ti on : absolute ; top:' + (y + sd) +
';1eft:' + (x + sd) + xzind + '">'
xstr+= '<P styl e = "' + xstyle + 'color :darkred"> ' + text + '</P></DIV>'
xstr+= '<DIV STYLE = "posi tion : absolute ; top:' + + ';left:' + x +
xzind + ' "> '
xstr+= '<P style =" ' + xstyle + ' color : si lver"> ' + text + '</P></DIV>'
xstr+= '<DIV STYLE = "posi tion : absolute ; top:' + (y + hd) + ' ; left:' +
(x + hd) + xzind + '">'
xstr+= '<P style = "' + xstyle + 'color:' + tcolor + '">' + text + '
document . w r i t e ( x s t r )
//
>
, ,
HTML-. z-Index, , , ,
- . z-Index , z-Index . z-Index
HTML-.
( ) .
sd hd,
.
HTML- , (. 4.4):
<HTML>
<HEAD><TITLE>3d < /TITLE ><HEAD>
<SCRIPT>
4.1.6.
. , () , '
, . . - -
188
4.
!]
5-J
. 4.4. , d3()
(, )
JavaScript, (
, ).
.
4.1.
189
,
HTML-
<IMG>. , IE4+.
. , .
0
100 alpha. 0 , .
100 , , . , alpha . . , .
, . ,
,
.
. - ,
.
alpha, , .
STYLE:
<IMG ID = "myimg" SRC = " p i c t . g i f "
, #, .
:
<HTML>
<STYLE>
190
4.
JavaScnptSpiobaMilter_d4.htm -Microsoft Interne! Egplo
. 4.5. alpha
:
d o c u m e n t . a l l . 11_ . f i l t e r s [ " _ " ] . =
, , :
d o c u m e n t . a l l . m y i m g . f i I t e r s [ " a l p h a " ] . o p a c i t y = 30
, alpha.
, IE4+.
IE5.5+ , Microsoft.
, :
# 11_ {filter: progid : DXImageTransf orm. Microsoft.
_()}
# m y i m g {filter: progid:DXImageTransform.Microsoft.alpha
(opacity = 70, style = 3)}
:
document.all.1_.filters["DXImageTransform.Microsoft.
_"]. =
4.1.
191
document.all.myimg.filters["DXImageTransform.Microsoft.alpha"].opacity = 30
, (, , , ).
() , . .
(, alpha),
. ,
,
/ , .
. applyQ play().
stopQ.
revealtrans. :
duration ( );
transition ( 0 23); 23 0 22, .
revealtrans . , , onload:
<HTML>
192
4.
. . ,
play(). (transition = 12),
.
, .
<HTML>
function transformO {
//
document . all .myimg. style .vi sibi li ty = "hidden" /*
*/
myimg. filters("revealtrans") .apply ()
/*
*/
myimg. style. v i s i b i l i t y = "visible"
//
*/
}
</SCRIPT>
</HTML>
, ,
: , .
:
. ,
, .
src , .
<|_>
<BODY onload = "transf orm2() ">
<IMG ID = "myimg"
function transform2() {
myimg. filters ("revealtrans") . apply ()
document . all .myimg. src = "pict2.gif"
myimg. fi Iters ("revealtrans") . play ()
}
</SCRIPT>
</HTML>
//
/*
*/
//
/*
*/
4.1.
193
, .
pictl.gif pict2.gif.
, , . .
<HTML>
<IMG ID = "myimg"
if (document.all.myimg.src.indexOf("pictl")!= -1) /*
*/
document.all.myimg.src = "pict2.gif"
else
document.all.myimg.src = "pictl.gif"
myimg.fiIters("revealtrans").play()
//
>
</SCRIPT>
</HTML>
src URL- ,
. transform3() , URL-, ,
URL- .
IE4+.
IE5.5+ , Microsoft.
,
.
:
<HTML>
<STYLE>
function transforms(){
//
myimg.fiIters("DXImageTransform.Microsoft.revealtrans").apply()
/*
*/
if (document.all.myimg.src.indexOf("earth")!= -1)
/*
*/
document.all.myimg.src = "sun.gif"
else
document.all.myimg.src = "earth.gif"
myimg.filters("DXImageTransform.Microsoft.revealtrans").play()
/'
*/
194
4.
</SCRIPT>
</HTML>
.
alpha revealtrans.
, . ,
. ,
:
<HTML>
<IMG ID = "myimg" onclick = "transforms ()" SRC = "earth.gif"
STYLE = "position.-absolute; top:10; left:50;
filter : revealtrans(duration = 3, transition = 12), alpha(opaci ty = 50)">
<SCRIPT>
function transform3() {
myimg.f iltersC'revealtrans") .apply ()
//
//
//
if (document . all .myimg. src . i ndexOf ( "pictl" ) != -1) /*
*/
4.1.
document.all.myimg.src = "pict2.gif"
else
document.all.myimg.src = "pictl.gif"
myimg.fliters("revealtrans").play()
195
/*
*/
</SCRIPT>
</HTML>
4.1.7.
( )
setlntervalQ.
2.8.
HTML- , <TEXTAREA>.
0,1.
. wrtextQ , .
value . wrtextQ setlntervalQ,
, , . 100. setlntervalQ
,
xinterval. clearlntervalQ
, wrtextQ,
.
<HTML>
<1> -</1>
<TEXTAREA ID = "mytext" ROWS = 8 COLS = 25></TEXTAREA>
<SCRIPT>
var i = 0
i++
}else
clearlnterval(xinterval)
//
}
</SCRIPT>
</HTML>
setlntervalQ
.
196
4.
4.2.
HTML-
top left .
STYLE <STYLE> ,
(, , , . .).
top left . ,
(, , . .).
, ,
, .
, setlntervalQ
setTimerQ, 2.8.
4.2.1.
, , :
function init_move(){
//
. . .
// move()
setlnterval("move()", )
}
function move() {
. . .
/* top left
*/
}
init_move()
//
, , . , init_move(),
setlntervalQ
move() . ,
setlnterva() , , . , move(), . setlntervalQ move()
, . . ( moveQ) ( setlntervalQ). ,
, init_move().
,
.
4.2.
197
<HTML>
<IMG ID="myimg" SRC="pict . gif " STYLE="posi tion : absolute ; top: 10; left : 20">
<SCRIPT>
function init_move() {
dx = 8
//
dy = 3
//
setlnterval ("move() " , 200)
move ()
//
function move(){
//
/* : */
var = parselnt (document . all .myimg. style . top)
var x = parselnt (document . all .my img. style . left)
/* : */
document .all .myimg. style. top = + dy
document . all .myimg. style . left = x + dx
}
init_move()
//
</SCRIPT>
</HTML>
, dx dy
move(). init_move() var, moveQ.
, . parselntQ .
: , , init_move() .
. :
function i ni t_move(xid , dx, dy) {
var prmstr = "'" + x i d + "'," +dx + "," + dy
/*
move() */
prmstr = "move(" + prmstr + ")"
setlnterval(prmstr , 200)
/*
move() */
}
function move(xid, dx , dy){
= parselnt (document . all [xid] . style . top)
x = parselnt (document . all [xid] . style . left)
document .all .myimg. style . top = + dy
document . all .myimg. style . left = x + dx
>
i n i t_move( " m y i m g " , 10, 5)
//
, setlntervalQ
moveQ . , setlntervalQ, ,
. , , .
198
4.
. ,
. , moveQ , , , ,
. ,
.
. clearlnterval(), , setlntervalQ.
, , setlntervalQ, , clearlntervalQ moveQ.
, moveQ , setlntervalQ.
, , :
function init_move(xid, dx, dy) {
var prmstr = "'" + xid + "'," +dx + "," + dy
/*
move() */
prmstr = "move(" + prmstr + ")"
idjnove = setlnterval(prmstr, 200)
/*
*/
}
function move(xid, dx, dy){
= parselnt(document.all[xid].style.top)
x = parselnt(document.all[xid].style.left)
document.all.myimg.style.top = + dy
d o c u m e n t . a l l . m y i m g . s t y l e . l e f t = x + dx
if (parselnt(document .all [xid] . style.left) > 350)
clearlnterval(id_move)
/*
*/
//
,
350 .
. , . , , ,
. ( 4.6). ,
, .
, . , .
199
4.2.
. 4.6.
4.5 ,
. ellipseQ ,
a moveQ , setlntervalQ.
4.5. ,
:
= 0
= 0
= 0
v a r t = -ztime
/* 0,
move() */
setlnterval("move('" + xid + "'," + alpha + "," + +"," + b + "," +
omega + "," + x0 + "," + y0 + "," + ztime + " ," + dt + ")",
ztime*1000)
/' moveO ztime, */
function move(xid, alpha, a, b, omega, x0, y0, ztime, dt) {
/* ,
ellipseO */
200
4.
4.5 ()
t+= ztime
/* , - */
var x = a*Math.cos((omega*t + dt)*Math.PI/180)
var = b*Math.sin((omega*t + dt)*Math.PI/180)
var as = Math.sin(alpha*Math.PI/180)
var ac = Math.cos(alpha*Math.PI/180)
document.all[xid].style.top = -x*as + y*ac + y0
document.all[xid].style.left = x*ac + y*as + x0
}
HTML-, , :
<1_>
<SCRIPT>
function ellipse(xid, alpha, a. b, omega, x0, y0, ztime,dt) {
. . .
//
}
function move(xid, alpha, a, b, omega, x0, y0, ztime, dt) {
...
//
}
var xstr = '<IMG ID = "myl" SRC = "pictl.gif"><IMG ID = "my2" SRC =
"pict2.gif">'
document.wri te(xstr)
ellipse("myl", 60, 100, 30, 10, 170, 300, 0.2, 0)
ellipse("my2", 80, 100, 130, 30,140, 300, 0.2, 0)
</SCRIPT>
</HTML>
ellipseQ moveQ ,
ellipse.js, HTML- :
<1_>
<SCRIPT SRC = " e l l i p s e . j s " > < / S C R I P T >
<SCRIPT>
, . ,
, , . ,
. (, ).
evalQ left top
. ( moveQ), , -
4.2.
201
setlntervalQ,
.
, curvemoveQ . ID , .
, . curvemoveQ move():
function curvemove(xid, , x e x p r , ztime) {
/* . 0.
:
x i d - id ,
ztime move(),
*/
if (!xid) return null
if (lyexpr) yexpr = "x"
if (Ixexpr) xexpr = "x"
if (Iztime) ztime = 100
x=Q
// ,
/* ,
*/
setlnterval("move('" + x i d + "', '" + + "', '" + xexpr + "')",
ztime)
}
//
202 _
4.
</SCRIPT>
</HTML>
50 10 . 100 50 .
curvemoveQ moveQ , , .
, ,
:
function curvemove(xid , yexpr, x e x p r , ztime, namevar) {
/* . 1.
:
xid - id ,
-
-
ztime move(),
namevar -
*/
if (!xid) return null
if (lyexpr) yexpr = "x"
if (Ixexpr) xexpr = "x"
if (Iztime) ztime = 100
if (Inamevar) namevar = "x"
eval(namevar + "= 0")
// ,
/* ,
*/
setlnterval ("move( ' " + xid + "', '" + yexpr + "', '" + xexpr + ", '"+
namevar + " ' ) " , ztime)
function move(xid, yexpr, xexpr, namevar) {
eval(namevar + "++")
document . all [xid] . style. top = eval(yexpr)
document . all [xid] . style. left = eval(xexpr)
}
,
namevar.
, namevar,
, eval(). , , :
curvemoveC'myimgl" , "100 + 100*Math . s i n ( 0 . 0 5 * w ) / (0.05*w) " , " 5 0 + w " , 50, " w " )
curvemove("myimg2" , "100 + 2 * t i m e ) " , "570 - t i m e " , 100, " w " )
. , , .
evalQ, . , .
4.2.
203
4.2.2.
HTML- . , , , , . , .
.
: ;
(
); ,
, . 4.6 ,
.
4.6.
<HTML>
<><11_> </1|_></>
<BODY id = "mybody">
<IMG ID="myimg" SRC = 'pict.gif ondragstart = "dragO" style =
"position: absolute; top:10; left:10">
</BODY>
<SCRIPT>
flag = false
//
var id_img = ""
function drag(){
flag = mag
id_img = event . srcElement . id
}
function mybody . onmousemove () {
if (flag){
//
document . all [id_img] .style. top = event . clientY
document . all [id_img] . style. left = event . clientX
204
4.
onclick , ,
. , mybody.
onmousemove() id_img. document.all[id_img],
document.all.idjmg.
, ,
. , . . : () other ().
. top: , . (-). , .
, -
, - ( ). , , ( Math.random()). (. 4.7). ,
, .
<5\ - MicioJ. 1
"'2
. 4.7.
: (shipl.gif), (ship2.gif).
HTML-
, :
<IMG ID = "myl" SRC = " s h i p l . g i f " ondragstart = "dblclO" STYLE =
" p o s i t i o n : a b s o l u t e ; top:10;left:10; v i s i b i l i t y : v i s i b l e " >
4.2.
205
, . ( 4.7).
4.7.
<HTML>
<HEAD><TITLE>FlepeMeuiaeMbie </TITLE></HEAD>
//
resizeO
v a r flag = false
var id_img = ""
//
function drag()
flag = Iflag
id_img = event.srcElement.id
// id ,
function mybody.onmousemoveO{
if (flag){
document.all[id_img}.style.top = event.clientY
document.all[id_img].style.left = event.clientX
resizeO
//
//
function action(){
v a r s,
xO,
xl, yl,
//
vl,
v2,
v3.
xid,
yid,
d,
206
4.
4.7 ()
var dmin = 20, smin = 2
/*
*/
for (i =0; i < document . images . length; i++){
s = 0
x0 = parselnt (document . images[i ]. style. lef t)
y0 = parselnt(document. images [i ]. style. top)
for ( j=0; ] < document . images . length; ]++){
vl = document . images [i ]. style .vi sibi li ty == "visible"
v2 = document . images! j] . style. visibility == "visible"
xid = document . images [i ]. id. substrCO, 2)
yid = document . images []]. id . substr (0,2)
v3 = xid. localeCompare(yid) != 0
//
if (( i != j)&&vl&&v2&&v3){
xl = parselnt(document . images [j ]. style. lef t)
yl = parselnt (document . images [j ]. style . top)
d = Math.sqrt((x0 - xl)*(x0 - xl) + (y0 - yl)*(y0 - yl))
if (d <= dmin) s++
//
if (s >= smax) {
if (Math. random()<0.5) z = i
//
else z = j
document . images [z] . style .vi sibi li ty = "hidden"
break
function resize(){
//
var , size
for (i = 0; i < document . images . length ; i++){
= parselnt (document . images [i ]. style. top)
size = Math. min(x, 180)
size = Math.max(size, 15)
document . images [i ]. style .width = size
document . images [i ]. style . height = 0.8*size
}
}
</SCRIPT>
</HTML>
,
action(). .
. , , (, ), , (,
). , . z-Index resize(), top.
. resizeQ :
function resize(){
var , size
207
4.2.
for (i =0; i < document . images .length; i++){
= parselnt (document . images [i ] . s t y l e . top)
size = Math.min(y, 180)
s i z e = M a t h . m a x ( s i z e , 15)
document . images [i] . s t y l e . w i d t h = s i z e
document . images [1] .style. height = 0.8*size
document . images [i ] . s t y l e . zlndex = x
, JavaScript z-index
.
4.8 HTML-, , <TEXTAREA>. . (-).
, , (. 4.8). , .
, , , ,
. ,
.
, resizetextQ , .
noKSMeHiMUS\leiitaiea.HTM - Microsoft Internet Exploier
find
-d
. 4.8.
4.8. , <TEXTAREA>
<HTML>
<><11> </11></>
<BODY i d = " m y b o d y " b a c k g r o u n d = " b l u e . g i f " >
4.
208
4.8 ()
<TEXTAREA ID="tl" ondblclick="drag()" STYLE = "position:absolute;
top:50; left: 10;fon-size:large">3To - reKCT</TEXTAREA>
<TEXTAREA ID="t2" ondblclick="drag()" STYLE = "position:absolute;
top:100; left:150"> - </>
<TEXTAREA ID="t3" ondblclick="drag()" STYLE = "position:absolute;
top:150; left:250">3io - TeKCT</TEXTAREA>
</BODY>
<SCRIPT>
resizetextO
//
//
var flag = false
var id_img = ""
function drag()
{
flag = !flag
id_img = event.srcElement.id
// id ,
//
I
function mybody . onmousemove () {
if (flag){
document . all [id_img] .style, top = event . clientY
document . all [id_img] . style . lef t = event . clientX
resizetextO
//
function resizetext () {
//
//
</SCRIPT>
</HTML>
,
resizetext() . , .
, , -
209
4.2.
HTML- (. 4.9).
: , . , , , . .
D:\DUNAEVVifiame_mdve - Miciosolt Internet Expluei
. ; D \DUNAEVotiammove.HT
?|
. 4.9.
-, ,
,
. ,
. -, , , , . , ,
, .
,
<IFRAME>. ( 4.9)
(), . ,
, HTML-. , , resizeframeQ.
210
4.
4.9.
<HTML>
<HEAD><TITLE> /TITLE ></HEAD>
<BODY ID = "mybody" background = "blue.gif">
</BODY>
<SCRIPT>
/* */
var ahref=new ArrayO)
ahref[0] = "graphic .htm"
ahref[l] = "examples.htm"
ahref[2] = "mybook.htm"
/* */
var xstr = ""
for (i=0; i <ahref. length; i++) {
/* */
xstr+= '<IFRAME width=200 ID="fr' + i + " SRC = "'+ahref[i] + '
STYLE[ = "posi tion: absolute; top:' + (5
25*i) + ' ; left:' + (10 + 30*i)
+ "></iframe>'
/* */
xstr+= '<IMG ondblclick="drag()" width=16 height=14 SRC = "pyKa.gif"
id="im' + i + '" STYLE = "posi tion : absolute"> '
document.write(xstr)
,flag = false
var id_img = ""
resizef rameO
//
//
function drag(){
flag=!flag
id_img = event.srcElement. id
id_img = "fr" + id_img.substr(2)
function mybody .onmousemoveO {
if (flag){
document . all [id_img] . style. top = event . clientY
document . all [id_img] . style. left = event . clientX
resizef rameO
I
4.3.
211
document.all[idfr].style.zlndex =
/* */
idimg = "1m" + i
/ / i d
document.all[idimg].style.top = y-5
document.all[idimg].style.left =
parselnt(document.all[idfr].style.left) -12
document.all[idimg].style.zlndex=document.all[idfr] .style.zlndex
}
}
</SCRIPT>
</HTML>
, , .
, . , ( <BODY>) rnybody.onmousemove() . - ,
. , , .
, , (, ) HTML- (-).
,
. ,
, - .
, , , , ( ). , , ,
.
4.3.
JavaScript
. , HTML- <TABLE>
<HR> . , , , ? , , ?
. 1x1 , , . , top left STYLE <IMG>.
, <IMG> , write().
,
, .
212
4.
4.3.1.
, .
, . HTML
:
<IMG SRC = " p o i n t . b m p " STYLE = " p o s i t i o n : a b s o l u t e ; t o p : y ; l e f t : x " >
point.bmp , ; , , . 1x1 . BMP, JPEG
GIF ( ).
, WIDTH HEIGHT ( ):
<IMG SRC = "point.bmp" STYLE = "position:absolute;top:y;left:x" WIDTH =
n HEIGHT = n>
WIDTH HEIGHT . 1x1
. ,
() , , .
,
xl, yl, 2, 2 . , .
:
function line(xl, yl, 2, 2 , ){
/* 0 */
/* xl, yl 2, 2 - - */
var clinewidth =
/*
*/
var xstr = "" // HTML-
var xstrO = '<IMG SRC="point.bmp"' + c l i n e w i d t h + '
STYLE="positlon:absolute; '
var k = (y2 - yl)/(x2 - xl)
//
var x = xl
//
/* , <IMG. . . > : * /
while (x <= 2) {
xstr += xstr9 + 'top:' + (yl + k*(x - xl)) + ': left:1 + x +'">'
x++
}
document.write(xstr)
//
}
lineQ ,
. top left STYLE. , left. , .
(top) , . .
213
4.3.
, , 45 (. 4.10). , . , 2 - xl.
, 2 = xl , , 0. , line() . , , .
.... I
"
. 4.10. , line()
line() ,
, . ,
, ,
(. 4.11). , , ,
, ( 4.10).
4.10. lineQ 1
// ,
v a r clinewidth =
if (!n)
c l i n e w i d t h = ' WIDTH=" + n + " HEIGHT=" + n
// HTML-
v a r xstr=""
&
214
4.
4.10 ()
var x s t r O = '<IMG SRC="point.bmp"' + clinewidtn + '
STYLE="position:absolute;'
var x, k, direct
(true){
if (!vertical){
xstr += xstrO + 'top:' + (yl + k*(x - xl)) +
left:' + +'">'
if (x == x2) break
if (direct) x*+
else x - }else{
xstr += xstrO + ' left: + (xl+k*(x-yl)) + '; top: 1 + x + '">'
if (x == y2) break
if (direct) x++
else x--
I
document.write(xstr)
//
, , , . , C:\Mon \1.... F
. 4.11. , lineQ 1
4.3.
215
.
. , , . , , .
. line()
: ( 4.11).
, . 0, .
4.11. line() 2 ( )
function line(pict_file, xl, yl, x 2 , y2, n, s){
/* 2 */
/* pict_file -
xl, yl -
x2, y2 -
n -
s -
*/
if (!pict_file)
//
pict_file = "point.bmp"
if (!s)
//
s = 0
v a r clinewidth = ""
// ,
//
if (!n)
//
clinewidth = " WIDTH=" + n + " HEIGHT=" + n
var xstr = ""
// HTML-
var xstrO = '<IMG SRC="'+ pict_file + '"' + clinewidth + '
STYLE="posi tion:absolute;"
var x, k, direct
var vertical = Math.abs(y2 - yl) > Math.abs(x2 - xl)
if (vertical){
direct = (y2 > yl)
//
x = yl
k = (x2-xl)/(y2-yl)
//
}else{
direct = (x2 > xl)
//
if (direct) x = xl
else x = x2
k = (y2 - yl)/(x2 - xl)
//
}
var i = 0
//
var draw = true
//
while (true){
if (!vertical){
if (draw)
xstr += xstrO + 'top:' + (yl + k*(x - xl)) + '; left:' + x + '">'
if (x == x2) break
if (direct) x++
else x-}else{
if
(draw)
&
216
4.
4.11 ()
x s t r += x s t r G + ' l e f t : ' + (xl + k * ( x - yl)) + '; t o p : ' + x + ' " > '
if (x == y2) break
if ( d i r e c t ) x++
else x - if
(s>0&&i>s){
draw = I d r a w
i =
I
document.write(xstr)
//
lineQ , (. 4.12). ,
.
, .
, .
. - Microsoft Internet Explorer
111
4 ; :;
!' |.^'"'
'-j,
. 4.12.
4.3.
217
4.3.2.
,
? , , . .
, . , , ,
, .
, . evalQ, , ( 4.12).
curve() :
(,
), , , , , (
) (. 4.13).
4.12. curve()
function curve(pict_f i le ,yexpr , x 0 , y0, t, n. s){
/* 0 */
/* pict_file -
-
0, 0 -
t - ( )
n -
s -
*/
if (lyexpr) return null
if ( !pict_f ile) pict_file = "point.bmp"
if (!s) s = 0
if (It) t = 0
var clinewidth = ""
if (!n)
clinewidth = 'WIDTH=' + n + 'HEIGHT=' + n
var x
xstrG = '<IMG SRO"' + pict_file + '"'' + c l i n e w i d t h +
1
STYLE = "posi tion:absolute; top: '
xstr = ""
var i = 0, draw = true
for(x = 0; x < t ; x++) {
if (draw)
xstr += xstrO + (y0 + eval(yexpr)) + '; left:' + (x0 + x) +'">'
if (i > s&&s > 0) {
draw = Idraw
i = 0
//
218
4.
-1 - Microsoft Inle .,
. 4.13. , curveQ
:
//
curve("","200-0.01**",1,100,200,3)
curve("","100.0*Math.sin(6/250*())",30,120,300,12,0) //
curve("","0.001***(-75)","",100,80,200,6,0)
curve() , (, ). ,
. . "" ( 4.13).
, 0. ,
.
4.13. curveQ
function curve(pict_file, yexpr, x e x p r , xO, y0, t, n, s){
/* 1 */
/* pict_file -
yexpr -
-
0, 0
t ( )
n
s
; (!yexpr) return null
if (!xexpr) xexpr = "x"
219
4.3.
if (!s) s = 0
if (! t) t = 0
var clinewidth = ""
if (!n)
clinewidth =
'WIDTH=' + n + 'HEIGHT=' + n
var x
document .wri t e ( x s t r )
}
//
(. 4. 14):
curve("",
curve("" ,
curve("" ,
curve("",
. 4.14. , curveQ 1
220
4.
,
. , .
. , , (. 4.15). , GIF-. ,
.
:\ HTM - Microsoft Internet Explorer
J
JLJ
. 4.15.
4.3.3. ,
, ,
. , , , , .
.
, (
), . .
4.3.
221
-, , : . -,
, , ,
, . ,
. , , ,
, .
. , . ,
, . , , .
4.3.4. ,
, , , , , .
, .
, ,
, (). , ,
(, ). .
. , , , . , , ( - ) .
, .
,
lineQ. .
.
,
(). ,
, . ,
, , . line()
document.write(xstr) return xstr.
4.14 , , (. 4.16).
222
4.
95\2. - Microsoft Internet E
. 4.16. ,
4.14. , ,
<SCRIPT>
/* , */
/* */
var aX = new Array("", "", "", "", "", "")
/' */
var aY = new Arrayd, 15, 13, 4, 8, 6)
var ky = 10, kx = 60
var x0 = 100, yO = 200
var xstr = ""
//
//
// ,
4.3.
223
document.write(xstr)
</SCRIPT>
//
/ /
//
, . ,
() ,
. .
4.3.5.
, . ,
(), ,
.
(, ) . ,
.
lineQ curve() - , HTML-. , .
, line() curveQ , HTML- .
,
( ).
, lineQ curve()
: document.write(xstr) return xstr.
,
. , ,
:
document.write(curve())
, :
224
4.
var xstr = ()
document.write(xstr)
, ,
curveQ line(), - , <DIV ID = . . .> ID, :
var cmycurve="<DIV ID = ' m y c u r v e ' > " + () + " < / D I V > "
document.write(cmycurve)
//
, <DIV> :
document.all.mycurve.innerHTML = ""
innerHTML, HTML, .
.
<IMG .. .>, ,
, . <DIV> .
. HTML-.
, :
document.all.mycurve.innerHTML = (_)
<DIV> <IMG. . .>,
, .
, , ,
( 4.15).
4.15.
<1_>
<BUTTON onclick = " r e d r a w n "></11>
<SCRIPT>
/* , c u r v e O
ID */
var c m y c u r v e = " < D I V ID = ' m y c u r v e ' > " + c u r v e ( " " , " 8 0 * M a t h . s i n ( 6 / 2 5 * x ) " ,
"80*Math.cos(6/50*x)",100,200,600,6,0) + "</DIV>"
document.write(cmycurve)
//
/* */
function r e d r a w O {
/*
( ) */
document.all.mycurve.innerHTML = c u r v e ( " " , " 6 0 * M a t h . s i n ( 6 / 2 5 * x ) " ,
"60*Math.cos(6/25*x)",100,150,300,2,0)
//
4.4.
if
(!n)
clinewidth =
225
'WIDTH=' + n + 'HEIGHT=' + n
var x
return xstr
}
// ,
</SCRIPT>
</HTML>
HTML- . .
,
.
4.4.
(,
) .
, , (, , , . .), .
,
, . :
31
31000 -
31000000 -
- . , , , .
, , ( ) . . , .
, 4. 16. , . , - .
.
226
4.
4.4
227
if (nNNl >0 ){
NN1 =speak(nNNl)
xyz = Right(NNl , 1)
NN1 = NN1 + " "
if (xyz == "a" || xyz == "" || xyz == "e")
NN1 = NN1 + "a"
else <
if (xyz != "")
NN1 = NN1 + "OB"
/* : */
function speak(k){
var yNl, yN2
if (k == 0)
return ""
if (k == 10)
return " "
if (k = 1 && k < 10)
return ed(k-l]
if (k >= 11 && k < 20)
r e t u r n d d [ k - 11]
4.
228
4.16 ()
if (k >= 20 && k <= 99) {
ck = ltrim(k. toStringO)
yNl = parselnt(l_eft(ck, 1))
yN2 = parselnt(ck.substr(l, 1))
ed[yN2-l]
return yN2==0 ? de[yNl-l] : de[yNl - 1]
I
if (k >= 100 && k <= 999){
k = ltrim(k. toStringO)
return so[parseInt(Left(k,l)) -1] + speak(parselnt (k . substr (1 , 2)))
function I t r i m ( x s t r ) {
if ( ! ( x s t r . i n d e x O f ( " ") == 0))
return x s t r
,
astr = astr . slice(i)
return astr.join(" ")
//
//
// ,
//
//
:
:
. 4.17.
229
4.5.
<1_>
4.5.
HTML-, , ,
, ,
(. 4.18). HTML <FORM>, . , forms. ,
. ,
, , (, ). -, HTML ,
.
9\>. - Microsoft Intel...
i
. 4.18.
, .
, <FORM> ACTION, Submit. . ACTION ,
, Submit.
230
4.
Submit, .
ACTION <FORM>.
- , .
, @ . @ , . onsubmit, Submit.
<HTML>
<FORM ID = "myform" METHOD=POST ACTI.ON="" ENCTYPE = "text/plain"
styIe="background:' 1 ">
:
:
<INPUT NAME="email_from" TYPE = "text" VALUE = "">
<P>
:<BR>
<TEXTAREA NAME = "" TYPE = "text" VALUE = " "></TEXTAREA>
<P>
231
4.5.
*/
var notext = Imyform.. value
var xtext = " "
if (noemail || notext){
event.returnValue = false
//
if (noemail)
alert(" " + xtext)
else
alert("HeT " + xtext)
} else
myform.action = "mailto:" + myform.email_to.value // ACTION
)
</SCRIPT>
</HTML>
JavaScnpl\piobaVPopM3.htm -.., 1
* ":
:
, jqqq@wwww.ru
:
!
. 4.19.
, . 4.19, :
email_to=xxx@yyyy.ru
email_from=qqq@wwww.ru
=
=0
, . , .
. returnValue
232
4.
false ( ).
, onsubmit ( ).
action .
action ,
event.returnValue = false ,
. HTML- :
<SCRIPT>
function myform.onsubmit() {
var noemail = myform.email_to.value.indexOf('@') == - I
var notext = Imyform..value
var xtext = " "
if (noemai1 || notext){
if (noemail)
alert(" " + xtext)
else
a l e r t C ' H e T " + x t e x t )
} else
m y f o r m . a c t i o n = " m a i l t o : " + m y f o r m . e m a i l _ t o . v a l u e // ACTION
}
</SCRIPT>
- ,
(. 4.20).
. ,
ACTION <FORM>.
, , -, - , .
(), action. - HTML--
. 4.20. -
4.5.
233
, . HTML-, .
<HTML>
<FORM ID = "myform" METHOD=POST ACTION="" ENCTYPE="text/plain"
style="background:'e0e0eO'">
<2> </2>
:
<INPUT NAME="email from" TYPE = "text" VALUE = "">
<P>
:<BR>
<TEXTAREA NAME = "" TYPE = "text" VALUE = " "></TEXTAREA>
<P>
. .
<HTML>
<FORM ID = "myform" METHOD=POST ACTION="" ENCTYPE="text/plain"
<P>
<! S u b m i t >
<INPUT NAME = "" TYPE = "submit" VALUE = "">
</FORM>
<SCRIPT>
alert("HeT ")
return false
//
} else
myform.action = "mailto:" + first + "@" + second + ".ru"
// ACTION
return = true
//
}
</SCRIPT>
</HTML>
4.
234
4.6.
4.6.1.
<SELECT> <OPTION>.
.
(. 4.21).
HTML-,
. . .
. selectedlndex
, <SELECT>, ( 0).
onchange ( ).
myselectionQ. SELECTED
<OPTION>. .
% JavaSciipt\pr\_. - Microsoft Internet Exploiei
, : [
. 4.21.
<1_>
, :
<5ELECT NAME="TEST" onchange ="myselection () ">
<>
<OPTION 51>
<>
235
4.6.
<>
</SELECT>
<SCRIPT>
function myselection() {
var testname, testnumber;
testnumber = document . all .TEST. selectedlndex
if (testnumber == 0)
testname="MaT . "
else{
if (testnumber == 1)
151=" ^
else{
if (testnumber == 2)
testname=" "
else
testname = " "
alertC'Bbi :
I
</SCRIPT>
</HTML>
testname)
.
( ),
<SELECT> SIZE = __ (. 4.22).
JavaSciipt\proba\pacKp_cnMCOK.htm - Microsoft Internet Exploiei
, :
. 4.22. ,
HTML-, , ( 4.17).
4.17.
<HTML>
, :
<SCRIPT>
var N_sel = 1
// ,
var aoptions= new A r r a y O
//
aoptions[0] = ""
aoptions[l] = ""
&
4.
236
4.17 ()
aoptions[2] = ""
aoptions[3] = ""
/* , , */
xstr=' <SELECT ID ="TEST" onchange = "myselection () "> '
for (i = 0; i <aoptions . length ; i++){
xprefix = (i == N_sel)? 'SELECTED =' + N_sel: "
xstr+= '<OPTION ' + xprefix + '>' + aoptions[i]
xstr+= '</SELECT>'
//
document .write(xstr)
function myselectionQ {
var testname, testnumber;
testnumber = document . all .TEST. selectedlndex
if (testnumber == 0)
testname="MaT . "
else{
if (testnumber == 1)
testname = " "
else{
i f (testnumber == 2)
testname = ""
else
testname = " "
alert("Bbi : "+ testname)
)
</SCRIPT>
</HTML>
4.6.2.
, , (. 4.23). , ?
. , 3 - \ . - Microsoft Internet Exploc
2;
,J
1 ( 2 |
1.1
1.2
. 4.23.
..;'
4.6.
237
: . , . URL- -
, JavaScript.
, , js. , menu_prm.js,
( 4.18).
. ,
, . , () . , menu_bld.js,
( 4.19).
, .
. , .
, HTML- :
<SCRIPT SRC = "menu_prm. j s " x / S C R I P T >
<SCRIPT SRC = "menu_bld. j s " x / S C R I P T >
<SCRIPT >buildMenu()</SCRIPT >
b u i l d M e n u ( ) , menu_bld.js.
,
menu_prm.js.
, () , .
. ,
, .
, ,
. , ,
.
, . ,
URL-, JavaScript, "javascript:", , .
, .
HTML-, . HTML-, HTML-,
. top left
, . , , buildMenu(). , HTML-, .
4.18. menu_prm.js
/* */
// :
var clBorder = ' b l u e '
//
.
&
238
4.
4.18 ()
var
var
var
var
clBglnact
clBgAct =
clFnlnact
clFnAct =
= "#83d6f5"
'#d6f4fe'
= 'blue'
'black'
// ( )
var cFontSize = '18'
var cFontFamily = 'times'
// :
var closeTimeout = 500
var selfPos = false
//
//
//
//
//
/* ('arial',
'courire', 'times' . .) */
// ,
/*
( true,
) */
// :
var menu = new ArrayO
menu[0] = new ArrayO
/* :
;
URL- JavaScript,
" j avascri pt:";
;
left (- );
top (- ) ;
width ( );
left (- )
top (- );
width ( ).
*/
menu[0][0] = new ' 1","", - ", 50,
10, 80, 50,1 20, 120)
menu[0][l] = new Array(" 1.1 , "javascript:hi story.go(-1)",
"")
menu[0][2] = new Array(" 1.2 , "http://www.yandex.ru", "")
menu[0][3] = new Array(" 1.3 , "javascript:
alert('!')"," ")
menu[l] = new ArrayO
menu[l][0] = new ' 2","",
130, 10, 80, 130, 120, 0)
menu[l][l] = new Array(" 2.1
menu[l][2] = new Array(" 2.2
menu[2] = new ArrayO
menu[2][0] = new ' 3"
http://www.chat.ru", "CHAT.RU", 210,
10, 80, 0, 0, 0)
4.19. menu_bld.js
var ie = document.all ? true
v a r overBox = ' '
var timerlD
false
// - ?
// HTML-
var barHtml = new ArrayO
barHtml[0] = '<DIV ID="divbarpos'
barHtml[1] = '" STYLE="position:absolute;left:
barHtml[2] = 'px;top:'
barHtml[3] = 'px;" onmouseover="openbox('
4.6.
239
// ( )
function buildMenuBarO {
//
for (i = 0; i < menu.length; i++){
var s = barHtml[0] + i + barHtml[l] + menu[i][0][3] + barHtml[2] +
menu[i][0][4] + barHtml[3] + i + barHtml[4] + i + barHtml[5] + i +
barHtml[6] + clBorder + barHtml[7] + i + barHtml[8] + menu[i][0][5] +
barHtml[9] + clBglnact + barHtml[10] + clFnlnact + barHtml[ll] +
menufi][0][0] + barHtml[12];
document.writeln(s);
!
function buildSubMenuO {
//
for (i = 0; i < menu.length; i++){
if (menu[1].length > 1) {
v a r s = boxHtml[0] + i + boxHtmltl] + menu[i][0][6] + boxHtml[2] +
menu[i][0][7] + boxHtml[3] + i + boxHtml[4] + clBorder + boxHtml[5] +
i + boxHtml[6]
for (j = 1; ] < menu[i].length; j++) {
var si = i +
var s2 = i + ' j+ J
240
4.
4.19 ()
s += boxHtml[7] + s2 + boxHtml[8] + si + boxHtml[9] + si +
boxHtml[10] + si + boxHtml[ll] + s2 + boxHtml[12] menu[i] [] [8]
boxHtml[13] + clBglnact + boxHtml[14] + clFnlnact boxHtml[15] +
menu[i][j][0] + boxHtml[16]
s += boxHtml[17]
document.wri teln(s)
i
function PosMenuO {
for ( i = 0 ; i < menu.length; i++) {
barCurr = document.all['divbarpos' + 1]
if (i > 0) {
barPrev = document.all['divbarpos' + (i - 1)]
barCurr.style.left = barPrev.offsetLeft +
barPrev.offsetWidth - 1
,
if (menu[i].length > 1) {
boxCurr = document.all['divbox' + i]
boxCurr.style.pixelTop = barCurr.offsetTop +
barCurr.offsetHeight - 1
boxCurr . style . pixelLeft = barCurr ..of f setLef t
I
function ResizeSubMenu() {
for (i = 0; i < menu.length; i++) {
if (menu[i].length > 1 && menu[i][0][8] <= 0) {
el = document.all['mnubox' + i]
w = document. all['divbarpos' + i].offsetWidth
if (el.offsetWidth < w) el.style.width = w
I
I
I
function openbox(x) {
paintLayer('mnubarpos' + x, active = true)
showLayer('divbox' + x)
for (i = 0; i < menu.length; i++) if (i != x) closebox(i, 0)
overBox = 'divbox' + x
window.status = menu[x][0][2]
I
function closebox(x, timeout) {
paintLayer (' mnubarpos ' + x, active = false)
clearTimeout (timer ID)
if (timeout == 0) hideLayer( 'divbox ' + x)
else timerlD = setTimeout (' hideLayer ("divbox '
closeTimeout)
overBox = ' '
window. status = def aultStatus
function clickbox(x) {
clickMenu(menu[x] [0] [1] )
\
x +
4.7.
241
function openboxpos(x, ) {
paintLayer('mnuboxpos' + x + '_' + , active = true)
overBox = 'divbox' + x
window.status = menu[x][y][2]
function closeboxpos(x, y) {
window.status = defaultStatus
paintLayer('mnuboxpos' + x + '_' + y, active = false)
function clickboxpos(x, y) {
clickMenu(menu[x][y][1])
function clickMenu(s) {
if (s.indexOf('javascript:') == 0) eval(s);
else if (s != '') window.location.href = s;
function paintLayer(layerID, active) {
if (layer = document.all[layerlD]) {
if (active) { clBg = clBgAct; clFn = clFnAct }
else { clBg = clBglnact; clFn = clFnlnact }
layer.style.backgroundColor = clBg
layer . style.color = clFn
function showLayer(layerlD) {
if (layer = document.all[layerlD]) layer.style.visibility = 'visible'
}
function h i d e L a y e r ( l a y e r l D ) {
if (layer = d o c u m e n t . a l l [ l a y e r l D ] && (overBox != layerlD))
document.all[layerlD].style.visibility = 'hidden'
}
,
.
(. 4.24). ,
, .
4.7.
, -, . ( , ) ,
. , . ,
, , .
242
4.
.)5\.1 Miciojoft Internet Explmet
^':
npacKu
1> 2.1
. 4.24.
TextRange.
, ,
<BODY>, <TEXTAREA>, <BUTTON> <INPUT TYPE = "text">.
,
HTML-, <BODY>.
. myfindQ, .
myfind() createTextRangeQ .
, , .
findTextQ , WORD. , scrollIntoViewQ , . selectQ
().
<HTML>
<BODY>
<INPUT TYPE = "text" N A M E = "WORD" VALUE = "" SIZE = 20 >
*/.
4.7.
243
</SCRIPT>
</HTML>
( , , ),
. , ,
? . , . , .
:
function myfind(){
if (IWORD.value) return
// ,
obj = document. body .createTextRangeO
obj .findText(WORD.value)
obj . scroll I ntoViewO
o b j . s e l e c t ()
}
, .
, . , ,
.
promptQ,
( )
. .
promptQ false,
. :
function myfind(){
WORD = prompt(", : ","")
if (IWORD) return
// ,
obj =document. body. createTextRangeO
obj.findText(WORD)
obj .scrollIntoViewO
obj.select ()
}
, .
alert().
,
, <TEXTAREA>. , <TEXTAREA>
.
( <BODY>) body,
<TEXTAREA>, <BUTTON> <INNPUT> ID NAME.
<HTML>
<INPUT TYPE = "text" NAME = "WORD" VALUE = "" SIZE = 20 >
<BUTTON onclick = "myfind()"></>
<P>
<TEXTAREA ID = "mytext">
<! , >
244
4.
</TEXTAREA>
<SCRIPT>
/*
, */
obj = document. all .mytext. createTextRangeO /*
*/
obj.findText(WORD.value)
obj . scrollIntoViewO
obj.select()
I
//
/*
*/
//
</SCRIPT>
</HTML>
4.8.
, , . , <TABLE>, <TR>, <TD> .
(, , , ,
. .). , . CSS , .
4.8.1.
, . rows,
cells. rows ,
, <THEAD> <TFOOT>. cells , <> <TD>.
, ID . , ID <TR>, ID
- > <TD>. () ,
0.
.
,
(. 4.25):
<HTML>
<TABLE ID = "mytab">
<> </>
<></><></><></>
<TR ID="rl">
<></><></><></>
</TR>
<TR ID="r2">
245
4.8.
<></><></><> </TD>
</TR>
<TR ID="r3">
<></><></><></>
</TR>
<TR ID="r4">
<></><></><></>
</TR>
</TABLE>
</HTML>
icrosott internet...
_ J
. 4.25.
:
document.all.mytab.rows[0]
document.all.mytab.rows[1]
document.all.mytab.rows[" rl" ]
document.all.mytab.cells[0]
//
//
/*
*/
/* ,
"" */
document.all.mytab.cells[3]
// , ""
document.all.mytab. cells[4]
// , ""
document.all.mytab.cells[]
// , ""
, : all ,
. ,
(
), .
( rows), ,
, cells,
. 0. , cells 0,1 2.
246
4.
/* ,
"" */
/* ,
document all .mytab. rows [1] . cells[0]
"" */
. /* ,
document all .mytab rows [1] . cells[l]
""*/
/* ,
document . all . mytab rows[2] . cells[0]
"" */
document all , mytab rows ["r2 "] .cellsfl] /* ,
"" */
. . IE4+
innerText innerHTML innerText
.
HTML-, innerHTML. ,
, innerHTML.
, innerHTML , innerText. ( ), .
document.all.mytab.rows[1].innerText
//
document.all.mytab.cells[3].innerText
//
document.all.mytab.rows[1].cells[2].innerText
//
/* : */
d o c u m e n t . a l l . m y t a b . r o w s [ I ] . c e l l s [ 2 ] . i n n e r T e x t = ""
/* : */
d o c u m e n t . a l l . m y t a b . r o w s [ 1 ] . c e l l s [ 2 ] . i n n e r H T M L = "<IMG S R C = ' p i c t . j p g ' > "
, , . , :
d o c u m e n t . a l l . m y t a b . r o w s [ ] . i n n e r T e x t = _
, , .
, , length, .
document.all.mytab.rows.length
//
document.all.mytab.cells.length
//
document.all.mytab.rows[2].cells.length /*
2 */
4.8.2.
insertRowQ.
, .
1'111(_). ,
.
. ,
247
4.8.
3, 0, 1 2 . ,
.
, : , , .
:
newrow = document . all .mytab. insertRowO //
newcell=newrow. i nsertCell (0)
// 0
newcell . 11=""
//
newceU=newrow. insertCeH (1)
4.8.3.
HTML
. .
.
,
. , , HTML-.
<HTML>
<SCRIPT>
/*
ah = new Array ("" , "
"")
/* */
ad = new A r r a y O
ad[0] = new A r r a y ( "" , ", "")
ad[l] = new A r r a y ( "" , ", " ")
ad[2] = new Array ("
"", "")
ad[3] = new A r r a y ( "
"", "")
strtab = "<TABLE>"
/* */
for(i=0; i<ah. length; i++){
strtab+= "<TH>" + ahti] + </TH>
/* */
for(i=0; i<ad. length; i++){
strtab+= "<TR>"
for(j=0; ]'<ad [i ]. length; j++){
strtab+=
//
strtab+="</TR>"
strtab+= "</TABLE>"
document .wri te(strtab)
</SCRIPT>
</HTML>
//
4.
248
4.8.4.
ActiveX, Simple Tabular Data (STD
). HTML- <OBJ ECT> , . , , , , () . STD
, .
.
-. (
Enter). .
, - (, ). ,
. (, Windows). , .
. , . ,
. , ,
, . ,
. . 4.26 , .
.
rib -
[|,<1
||
||
||
||
||[
. 4.26.
4.8.
249
<> <PARAM>, . :
FieldDelim ();
"|";
D a t a U R L (URL-) ;
mydb.txt;
UseHeader ,
.
ID <OBJECT> ,
. , , :
<PARAM NAME = "RowDelim" VALUE="&# A S C I I - ; " >
VALU
HAM E1 'Ap(n,lUate"
. 4.27. , STD,
<HTML>
<OBJECT ID = "mydbcontrol"
CLASSIC = "CLSID:333C7BC4-460F-11D0-BC04-0080C7055A83">
</OBJECT>
<SCRIPT>
alert(mydbcontrol.tnnerHTML)
</SCRIPT>
</HTML>
mydb.txt,
HTML- (. 4.28):
<TABLE DATASRC = mydbcontrol BORDER = 5>
<THEAD>
<> </><></><></>
</THEAD>
<TR>
250
4.
<TD><SPAN
<TD><SPAN
<TD><SPAN
</TR>
</TABLE>
DATAFLD
DATAFLD
DATAFLD
""></SPAN></TD>
""></5></>
""></SPAN></TD>
I J
^
.^ !
:|
||
. 4.28. , STD
<1_> DATASRC
STD ( ID <OBJ ECT>). <TD>, <SPAN>,
DATAFLD . .
. , , , . , . , () <TABLE>.
STD <TABLE>
. <TABLE>, , ,
. .
, STD : STD
( ), <TABLE> STD ,
.
,
HTML-. ,
, <TD> DATA FORM ATAS - " h t m l " .
251
4.8.
AoK.)MeHTbi\JS\mjpdb.h<ni - Microsoft Inlernel Exploi
; ;(
Cjpwe
1; 1
:1
. 4.29. , <IMG>
,
, HTML-. ,
, , , (. 4.29). :
<!_>
<OBJECT ID = "mydbcontrol"
CLASSID = "CLSID:333C7BC4-460F-11D0-BC04-0080C7055A83">
<PARAM NAME = "FieldDelim" VALUE="|">
<PARAM NAME = "DataURL" VALUE = "mydb.txt">
<PARAM NAME = "UseHeader" VALUE = true>
</OBJECT>
<TABLE DATASRC = tfmydbcontrol BORDER = 5>
<THEAD>
<> </><></><></>
</THEAD>
<TR>
252
4.
<TD><SPAN DATAFLD = ""></5></>
<TD><SPAN DATAFLD = ""></SPAN></TD>
<TD><SPAN DATAFLD = "" DATAFORMATAS = "html"> </SPAN></TD>
</TR>
</TABLE>
</HTML>
mydb.txt:
||
|j<IMG SRC='pictl.jpg'>
||<IMG SRC=' pict2.jpg'>
||<IMG SRC='pict3.jpg'>
||<IMG SRC='pict4.jpg'>
, STD .
, , () .
:
<PARAM NAME = "Fi UerColumn" VALUE = "_"
<PARAM NAME = "Fi1terCriterion" VALUE = "_"
<PARAM NAME = " F i l t e r V a l u e " VALUE =
()
:
_ _
, ,
"",
:
<PARAM NAME = "Filter-Column" VALUE = ""
<PARAM NAME = "FiIterCriterion" VALUE = "=="
<PARAM NAME = "FilterValue" VALUE = ""
= ( ), ==
( ), != (), > (), < (), >= ( ), <=
( ).
() ,
,
. , , :
<PARAM NAME = "FiIterCriterion" VALUE = "="
<PARAM NAME = "FilterValue" VALUE = ""
,
. CaseSensitive:
<PARAM NAME = " C a s e S e n s i t i v e " VALUE = >
ASCII-
. , ,
, :
4.8.
253
ASCII-
. , :
<PARAM NAME="SortAscending" VALUE=0>
VALUE=1 , .
STD recordset,
( ).
:
11_ . recordset,
, mydb.recordset.moveNextQ
.
:
movePreviosQ ;
moveNextQ ;
moveFirstQ ;
moveLastQ .
moveNextQ movePreviosQ eof ( ) bof ( ). ,
,
moveNextQ. , , movePreviosQ. , , , , . ,
() ,
STO - Microsoft Internet Explorer
. 4.30.
254
4.
(, ). .
(,
),
HTML-:
<TR><TD>
<INPUT TYPE = "text" DATASRC = #mydbcontrol DATAFLD = "">
</TD></TR>
, DATASRC DATAFLD
. 4.20 HTML, (. 4.30). , .
4.20. ,
<1>
<HEADER><TITLE>npHMep S T D < / T I T L E > < / H E A D E R >
<OBJECT ID = "mydbcontrol"
CLASSID = "CISID:333C7BC4-460F-11D0-BC04-0080C7055A83">
<PARAM NAME = "Fi eldDelim" VALUE = "|">
<PARAM NAME = " D a t a U R L " VALUE = " m y d b . t x t " >
<PARAM NAME = " U s e H e a d e r " VALUE = true>
</OBJECT>
<! >
<TABLE WIDTH = 75%>
<TD>
<INPUT TYPE = "text" DATASRC = #mydbcontrol DATAFLD = "" >
</TD></TR>
<><></>
<TD><INPUT TYPE = "text" DATASRC = #mydbcontrol DATAFLD="HMfl">
</TD></TR>
<><></>
<TD><SPAN DATASRC = #mydbcontrol DATAFLD = "" DATAFORMATAS
"html"></SPAN>
</TD></TR>
</TABLE>
<P>
<!
<INPUT NAME = "cmdFirst" TYPE = "BUTTON" VALUE = ""
onclick = "FirstO ">
<INPUT NAME = "cmdPrevious" TYPE="BUTTON" VALUE="<"
onclick = "PreviousO ">
<INPUT NAME="cmdNext" TYPE="BUTTON" VALUE=">"
onclick = "Next()">
<INPUT NAME="cmdLast" TYPE="BUTTON" VALUE=">>"
onclick = "LastO ">
<SCRIPT>
function FirstO {
mydbcontrol . recordset .move Fi rst ()
//
4.8.
function PreviousO {
255
/ /
if (! mydbcontrol.recordset.bof)
mydbcontrol.recordset.movePreviousO
I
function Next() {
if (! mydbcontrol.recordset.eof)
mydbcontrol.recordset.moveNextO
//
function Last() {
mydbcontrol.recordset.moveLast()
//
</SCRIPT>
</HTML>
, , <INPUT>, <SPAN> DATAFORMATAS = "html".
- . , ,
.
STD
-. HTML- , ,
,
. ,
. 4.8.7 , STD.
4.8.5.
.
. STD
, , <OBJECT> ( 4.21).
. .
<OBJECT> </>, , obj. sort(field), .
obj , , .
sort() HTML- <> , obj. outerHTML
STD . .
4.
256
4.21.
<HTML>
<OBJECT ID = "mydbcontrol"
CLASSID = "CLSID:333C7BC4-460F-11D0-BC04-0080C7055A83">
'FieldDelim" VALUE="|">
<PARAM NAME
'DataURL" VALUE = "mydb.txt">
<PARAM NAME
'UseHeader" V A L U E = true>
<PARAM NAME
"SortColumn" VALUE
<PARAM NAME
'SortAscending" VALUE=1>
<PARAM NAME
</OBJECT>
<TABLE DATASRC = tfmydbcontrol BORDER = 5>
<THEAD>
// STD
var x = document.all.mydbcontrol.innerHTML // ,
<object>
function sort(field) {
// field
var = document.all.mydbcontrol
y.outerHTML = obj + '<PARAM NAME = "SortColumn" VALUE="' + field +
"'></OBJECT>'
}
</SCRIPT>
</HTML>
. . , , . <PARAM NAME="SortAscending" VALUE=0>.
4.8.6.
, . ( 4.22) , () ()
: _ = .
, . (. 4.31).
257
4.8.
AOK>|MeHTbiVJS\mydblltr htm - Miciosoft Internet Exp... f
. .
;:
:
|^
|
. 4.31.
, , . , , .
, , STD, , . outerHTML
4.22.
<HTML>
<>:</>
<! >
<SELECT NAME = "FLD">
<OPTION value = "">
<OPTION value = "">
</SELECT>
<BR>
<! >
<INPUT NAME = "IMP" VALUE ="" TYPE = "text">
<P>
<BUTTON onclick = "filter()">npHMeHHTb</BUTTON>
<HR>
<! STD>
258
4.
4.22 ()
<OBJECT ID = "mydbcontrol"
CLASSID = " C L S I D : 3 3 3 C 7 B C 4 - 4 6 0 F - 1 1 D 0 - B C 0 4 - 0 0 8 0 C 7 Q 5 5 A 8 3 " >
<PARAM NAME = " F i e l d D e l i m " V A L U E = " | " >
function filter() {
//
var cpar = ""
//
if (INP.value){
//
cpar="<param name='FiIterColumn' value = '"+FLD.value+"'>"
cpar+= "<param name='FiIterValue' value = '" + INP.value+" ' >"
cpar+= "<param name='FiIterCriterion' value = '=' >"
cpar+="<PARAM NAME='CaseSensitive' VALUE = false>"
}
document.all.mydbcontrol.outerHTML = obj + cpar + "</OBJECT>"
}
</SCRIPT>
</HTML>
, , .
4.8.7.
,
. , .
,
( ) -. , search.txt. () !
4.8.
259
2. , HTML, .
.
, :
1|2
_|
:
1|2
5TD Simple Tabular Data|<a href='db0.htm'> (5TD)</a>
|< href='change.htm'> </>
E-mail Email |< href='mail.htm'> </>
|< href=' ellipse.htm'> </>
|< href='ellipse.htm'>3 </>
|< href='bordur.htm'> 1 </>
map search|<a href='search.htm > </>
|< href='findtext.htm'> </>
AFP|a href='afp.htm'></>
eval()|<a href='eval .htm' </>
web- web-|< href='mybook.htm'></>
,
, -. , , , , ,
db0.htm. ,
, db0.htm.
, ,
.
. , , , ,
. .
. , ,
. , ; . .
.
, .
:
. ,
(. 4.32).
STD, search.txt.
STD . , , ,
. pi.
2.
. , STD ( )
(. 4.8.4).
260
4.
" . Web- - Microsoft Internet Explorer
Jiflll
:, ^^-^^^
MPf
mm
^(..13'%
f
||^|||,-!*.
; !'
*
*
. ]
:
. 4.32.
. ,
. ,
.
4.23 .
4.23.
<HTML>
<! >
<OBJECT ID = ' f n d l 1
CLASSID = ' C L 5 I D : 3 3 3 C 7 B C 4 - 4 6 0 F - 1 1 D 0 - B C G 4 - 0 0 8 0 C 7 0 5 5 A 8 3 ' >
<PARAM NAME = ' Fi eldDel i m ' V A L U E = ' r >
<PARAM NAME = ' D a t a U R L ' V A L U E = ' s e a r c h . t x t ' >
<PARAM NAME = ' U s e H e a d e r ' V A L U E = t r u e >
<PARAM NAME = ' C a s e S e n s i t i v e ' VALUE=false>
</OBJECT>
<! >
<OBJECT ID = ' f n d 2 '
CLASSID = 'CLSID:333C7BC4-460F-11D0-BC04-0080C7055A83'>
1
<PARAM NAME = 'FieldDelim
VALUE='|'>
<PARAM NAME = 'DataURL 1 VALUE='search.txt'>
<PARAM NAME = 'UseHeader 1 VALUE=true>
<PARAM NAME = 'CaseSensitive' VALUE=false>
<PARAM NAME = 'CharSet' VALUE='windows-1251'>
4.8.
261
</OBJECT>
<! >
<! >
<INPUT TYPE = "text" NAME = "WORD" VALUE = "" SIZE = 20>
<! >
<BUTTON onclick = "findkeyword()">noHCK</BUTTON><BR>
<! >
< ID = 'rezult'></B>
<! >
<TABLE STYLE = ' v i s i b i l i t y : h i d d e n ' >
<TR>
<TD><INPUT NAME = 'fl' DATASRC = #fnd2 DATAFLD = 'pl'x/TD>
</TR>
</TABLE>
<! >
<TABLE ID = 'mytab' DATASRC = #fndl WIDTH = 350 ALIGN = LEFT
STYLE = 'visibility:hidden'>
<TR>
<TD><SPAN DATAFLD = 'p2' DATAFORMATAS = 'html'></SPAN></TD>
</TR>
</TABLE>
<SCRIPT>
var obj = "<OBJECT ID = fndl "
obj+="CLASSID='CLSID:333C7BC4-460F-llD0-BC04-0080C7055A83'>"
obj+="<PARAM NAME='FieldDelim' VALUE='r>"
obj+="<PARAM NAME='DataURL' VALUE='search.txt'>"
obj+="<PARAM NAME='UseHeader' VALUE=true>"
obj+="<PARAM NAME='CaseSensitive' VALUE=false>"
function findkeywordO {
if (IWORD.value) return
var xfItr = "", , cpar
fnd2.recordset.moveFirst()
//
//
/* 1-
*/
//
while (!fnd2.recordset.eof){
= fl.value.toLowerCaseO
if (.indexOf(WORD.value.toLowerCase())>=0){ //
xfltr = fl.value
/*
*/
break
}
fnd2.recordset.moveNext()
/*
*/
}
if (Ixfltr)
document.all.rezult.innerText = " "
else
document.all.rezult.innerText = "
/* : */
cpar = obj + "<param name = 'FiIterColumn' value = 'pl'>"
cpar+= "<param name = 'FiIterCriterion' value = '='>"
cpar+= "<param name = 'FiIterValue' value = '" + xfltr + "'x/OBJECT>"
^
262
4.
4.23 ()
document.all.fndl.outerHTML = cpar
/*
*/
//
m y t a b . s t y l e . v i s i b i l i t y = "visible"
}
</SCRIPT>
</HTML>
findkeywordQ ,
, !
. , xfl.tr
2.
, . outerHTML STD . . .
, . .
. , , ,
, . STD , ! 2. .
, , innerHTML result. ( 4.24).
4.24.
<HTML>
<! >
<OBJECT ID = 'fndl 1
CLASSID = 'CLSID:333C7BC4-460F-11D0-BC04-0080C7055A83'>
1
<PARAM = 'FieldDelim
VALUE='|'>
<PARAM NAME = 'DataURL 1 VALUE='search.txt'>
<PARAM NAME = 'UseHeader' VALUE=true>
<PARAM NAME = 'CaseSensitive' VALUE=false>
</OBJECT>
<! >
<! >
<INPUT TYPE = "text" NAME = "WORD" VALUE = "" SIZE = 20>
<! >
<BUTTON onclick = "f indkeywordO "></1><>
<! >
< ID = 'rezult'></B>
<! >
<TABLE STYLE = ' v i s i b i 1 i t y : h i d d e n ' >
<TR>
<TD><INPUT NAME = 'fl 1 DATASRC = #fndl DATAFLD = 'pi' ></TD>
<TD><INPUT NAME = 'f2' DATASRC = #fndl DATAFLD = 'p2'
DATAFORMATAS = "html"></TD>
</TR>
</TABLE>
4.8.
263
<SCRIPT>
function findkeyword() {
// ,
if (IWORD.value) return
//
var xrezult = "",
fndl.recordset.moveFirst()
// 1-
while (!fndl. recordset.eof){
//
= fl .value.toLowerCaseO
if (.indexOf(WORD.value.toLowerCase())>=0){ //
xrezult+= f2.value +"<BR>"
//
}
fndl.recordset.moveNext()
//
}
if (Ixrezult
document.all.rezult.innerHTML = " "
else
document.all.rezult.innerHTML = xrezult
}
</SCRIPT>
</HTML>
4.8.8. HTML-
HTML- ,
STD.
, HTML- . <1_>, . ,
. , .
, HTML-
(). HTML:
.
HTML-:
<|_>
<! >
<OBJECT ID = 'mydbcontrol'
CLASSID = 'CLSID:333C7BC4-460F-11D0-BC04-0080C7055A83I>
<PARAM NAME = 'FieldDelim' VALUE='|'>
<PARAM NAME = 'DataURL' VALUE='mydocum. htm'>
<PARAM NAME = 'UseHeader' VALUE=true>
</OBJECT>
<TABLE DATASRC = #mydbcontrol WIDTH = 350>
<TR>
<TD><SPAN DATAFLD = '<HTML>' DATAFORMATAS = 'html'></SPAN></TD>
</TR>
</TABLE>
</HTML>
, <HTML> .
, DATAFLD = "<html>". , (, , . .),
.
264
4.
HTML-. 4.25 , .
4.25. HTML-
<SCRIPT>
/* HTML- */
/* (URL) HTML- */
var aurl = new A r r a y O
aurl[0] = "htmll.htm"
aurl[l] = "html2.htm"
var tabwidth=800;
/* ,
HTML- */
/* , STD */
var xobject = new A r r a y O
xobject[0] = '<OBJECT ID="idobj'
// id
xobject[l] = '" CLASSID="CLSID:333C7BC4-460F-11D0-BC04-0080C7055A83">'
xob]'ect[l] += '<PARAM NAME = "FieldDelim" VALUE = "|">r
xobjectfl] += '<PARAM NAME = "UseHeader" VALUE = tme>'
xobject[l] += '<PARAM NAME = "CharSet" VALUE = "windows-1251">'
xobject[1] += '<PARAM NAME = "DataURL" VALUE ="'
xobject[2] = "'></OBJECT>'
/* */
var xtab = new ArrayO
xtab[0] = '<TABLE WIDTH=' + tabwidth + ' DATASRC = #'
xtab[l] = 'XTRXTDXSPAN DATAFLD=" <ritml>" DATAFORMATAS = " html" > '
xtab[l] += '</SPAN></TD></TRx/TABLE> '
var sobj = "";
for (i = 0; i < aurl.length; i++) {
sobj += xobject[0] + i + xobjectll] + aurl[i] + xobject[2] + xtab[0] +
'idobj' + i + xtabfl]
}
document.write(sobj)
</SCRIPT>
HTML-:
htmll.htm:
<HTML>
<> 1</>
<image src="folder.gif">3To -
<a href="db0.htm">OnncaHne </>
<button onclick="alert('!!!')"></>" -
</HTML>
html2.htm:
<HTML>
<> 2</>
<1> - .<1>
</HTML>
HTML-, ,
, . 4.33. .
(, ),
4.8.
265
1
Q -
i
1||| -
2
- .
. 4.33. HTML-
HTML-.
DataURL.
(
<IFRAME>) HTML-, , , .
, . , <HTML> ,
, ( HTML)
( ).
4.8.9.
,
( - ) . . ,
.
. ,
, ,
JavaScript .
266
4.
. 1.7.2.
. HTML (
STD), . . , , <1_> ID = "mytab",
. , , .
, parseFloatQ parselntQ. , :
m y a r r a y = new A r r a y O
f o r ( i = 0; i< d o c u m e n t . a l l . m y t a b . r o w s . l e n g t h ; i++){
myarray[i] = parseFloat(document.all.mytab.rows[i].cells[n])
>
parseFloatQ,
. , , , statisticQ,
1.7.2.
, STD. ,
. 4.26 HTML-
STD, , , .
4.26. HTML- STD
<HTML>
<! >
<OBJECT ID = 'mydatacontrol'
CLASSID = 'CLSID:333C7BC4-460F-11D0-BC04-0080C7055A83'>
<PARAM NAME = 'FieldDelim' VALUE='|'>
<PARAM NAME = 'DataURL' VALUE='mydata.txt'>
<PARAM NAME = 'UseHeader' VALUE=true>
</OBJECT>
<! >
<TABLE ID="mytab">
<TR>
<TD><INPUT NAME = 'zp' DATASRC = #mydatacontrol
DATAFLD = '' onchange = "zpchangeO">
</TD>
<! >
</TR>
</TABLE>
<>
< ID = "sum"></B>
<SCRIPT>
4.8.
var azp = new Array()
zpchange()
267
//
function zpchangeQ {
var 5=0, 1 = 0
mydatacontrol.recordset.moveFirst()
// 1-
while(!mydatacontrol.recordset.eof){
azp[i] = parseFloat(document.all.mytab.zp.value)
S+= azp[i]
mydatacontrol.recordset.moveNextO
//
i++
}
document.all.sum.innerText = S
// S
}
</SCRIPT>
</HTML>
, mydata.txt.
, . , .
S
< ID = "sum">.
4.8.10. -
,
, .
, HTML-
.
( ) - , . , , , . , ,
. . ,
.
FileExistsQ (FileSystemObject), 5.
, ActiveX, . . , .
. , ActiveX
. , ,
, () (). ,
-.
268
4.
HTML- URL- .
password myspecurl , , myspecfile.txt :
password]myspecurl
myspecfile|http://www.myweb.ru/mypage.htm
URL- , , .
HTML-
, ( 4.27). , . : , . , , .
, . , .
4.27. HTML-
<HTML>
<> </>
:
<INPUT ID = "pwl" TYPE="text" VALUE="">
<BUTTON ID = "pwenter">BBOfl</BUTTON>
<B ID = "dbelem"></B>
<SCRIPT>
function pwenter.onclick() {
if (Idocument.all.pwl.value)
//
return
dbstr = '<OBJECT ID = "mydbcontrol"' +
'CLASSID = "CLSID:333C7BC4-460F-11D0-BC04-0080C7055A83">' +
'<PARAMNAME = "DataURL" VALUE = '" + document.
all. pwl .value + '.txt"> ' +
'<PARAM NAME="FieldDelim" VALUE="|">' +
'<PARAM NAME = "UseHeader" VALUE = true></OBJECT>' +
'<TABLE STYLE = "visibility:hidden"><TR><TD>' +
'<INPUT ID = "pw2" TYPE = "text" DATASRC = "#mydbcontrol"' +
'DATAFLD = "password"></TD><TD>' +
'<INPUT ID = "xurl" TYPE = "text" DATASRC = "tfmydbcontrol"' +
'DATAFLD = "myspecurl"x/TD></TRx/TABLE>'
document.all.dbelem.innerHTML=dbstr /*
*/
setTimeout ("validationO ", 1000)
//
}
function validationO {
// ,
if (document.all.pwl.value == document.all.pw2.value){ /*
*/
document.all.pwl.value = ""
window.location.href = document.all.xurl .value // ,
}else
//
alert(" !")
}
</SCRIPT>
</HTML>
4.8.
269
1 , , innerHTML
. , , .
. ,
,
cookie-,
. 2.9. ,
. cookie-
, . cookie-. ,
, (
). .
.
, ,
cookie-. , .
4.28 HTML- , cookie- myspecrecord.
4.28. HTML- ,
cookie-
<HTML>
<> </>
< href="#" ID ="myref" onclick="pwvalid() "></>
<B ID = "dbelem"></B>
<SCRIPT>
var pw
/*
cookie */
function pwvalid(){
pw = readCookie("myspecrecord")
if (!pw)
pw = pwinputO
else
pwenterO
//
// cookie-
/*
cookie- */
/* ,
pwenterQ */
/* ,
- */
}
function pwinput(){
//
var inpstr = ' :<INPUT ID = "pwl" TYPE="text" VALUE="">'+
'<BUTTON onclick = "pw = document.all.pwl.value; pwenter()">
</BUTTON>'
d o c u m e n t . a l l . m y r e f .outerHTHL = inpstr
}
function
pwenter(){
//
&
4.
270
4.28 ()
if
(!pw)
//
return
dbstr = '<OBJECT ID = "mydbcontrol" CLAS5ID =
"CLSID:333C7BC4-460F-11D0-BC04-0080C7055A83">' + ,
'<PARAM NAME = "DataURL" VALUE = "' + pw + '.txt"> ' +
'<PARAM NAME="FieldOelim" VALUE="|">' +
'<PARAM NAME = "UseHeader" VALUE = true></OBJECT><TABLE STYLE =
"visibility:hidden"><TR><TD>'+
'<INPUT ID = "pw2" TYPE = "text" DATASRC = "tfmydbcontrol" DATAFLD =
"password"></TD><TD>' +
'<INPUT ID = "xurl" TYPE = "text" DATASRC = "tfmydbcontrol" DATAFLD =
"myspecurl"></TD></TR></TABLE>'
document.all.dbelem.innerHTML=dbstr
//
setTimeout("validationO",1000)
//
function validationO {
//
//
if (pw == document.all.pw2.value){
// ,
window.location.href = document.all.xurl.value
//
v a r d= new Date()
var d2=d.getTime()+(365*24*60*60*1000)
d.setTime(d2)
II cookie-
writeCookieC'myspecrecord' pw, d) // cookie-,
}else
//
alert(" !")
\
function readCookie(name) {
// cookie-
var xname = name + "="
var xlen = xname.length
var clen = document.cookie.length
var i = 0
while(i < clen){
var ] = i + xlen
if (document.cookie.substring(i, j) == xname)
return getCookieVal(j)
i = document.cookie.indexOf(" ",!) + 1
if (i == 0) break
return null
function getCookieVal(n){
/* ,
readCookieO */
4.9. Flash-
271
4.9. Flash-
, Macromedia Flash 5.0 6.0 (MX),
JavaScript.
, JavaScript, , ActionScript.
, ActionScript () JavaScript. , -
4.
272
'
;<>
Cgpenc
'^
1 <$
Flash
JavaScript
Flash-
[ Flash- JavaScript
<HTML>
<HEAD>
<meta http-equiv = Content-Type content = "text/html;
windows-1251">
charset =
4.9. Flash-
273
<> J a v a S c r i p t Flash</TITLE>
</HEAD>
<BODY BGCOLOR = "#e0e0e0">
<! Flash- >
<OBJECT CLASSID = "clsid : D27CDB6E-AE6D-llcf-96B8-444553540000"
CODEBASE =
"http://download.fflacromedia.com/pub/shockwave/cabs/flash/
swflash.cab#version = 6,0,0,0"
WIDTH = "287" HEIGHT = "261" id = "myflash" ALIGN="">
<PARAM NAME = movie VALUE = "myflash.swf">
<PARAM NAME = quality VALUE=high>
<PARAM NAME = wmode VALUE = transparent
<PARAM NAME = bgcolor VALUE=#FFFFFF>
<EMBED src = "myflash.swf" quality=high wmode=transparent bgcolor =
#FFFFFF WIDTH = "287" HEIGHT = "261" NAME = "myflash" ALIGN = ""
TYPE = "application/x-shockwave-flash"
PLUGINSPAGE = "http://www.macromedia.com/go/getflashplayer">
</EMBED>
</OBJECT>
, 15-<>
<INPUT TYPE = "text" NAME = "inputtext" SIZE = 40 onchange = getit()>
</BODY>
<SCRIPT>
function geti t(){
document.myflash.SeWariable("inFlash", inputtext.value)
</SCRIPT>
</HTML>
<OBJECT> ActiveX,
Flash- 6.0 (MX), 5.0. ,
, myflash.swf. CODEBASE
<OBJECT> URL- ,
. , IE5+ Flash-
. <EMBED> Netscape Navigator. HTML- <INPUT> . ( onchange)
getit(), JavaScript.
SetVariable() inFlash
inputtext.value. ,
. SetVariable()
Flash-, ID = "myflash". inFlash () Flash-. <PARAM NAME = wmode
VALUE = transparent^ . Flash- -.
, Flash-, HTML- ,
274
4.
NswRoman Cyr
jf ['
'
-.
iltilint
^7 pjoirr^,!
- '
JiiifW
'
, '
... ;. ,: ^_..'
4.9. Flash-
275
myflash.fla.
, .
HTML- SWF,
.swf. Publish, File ()
Flash. File Publish Settings
( > ).
swf-, Flash- . HTML-, HTML-
( <OBJECT>), Flash-
, .
HTML- .
4.9.2. JavaScript
Action Script
ActionScript Flash-
, JavaScript.
JavaScript-
, ActionScript. ,
JavaScript. , ActionScript, (. 4.4)
JavaScript?
JavaScript ActionScript
:
g e t U R L ( " j a v a s c r i p t : _()")
Flash- ,
, JavaScript. ,
ActionScript,
JavaScript.
HTML- <OBJ ECT>, Flash- , , :
, . 4.30 .
4.30. JavaScript ActionScript
<HTML>
<HEAD>
<meta http-equiv = Content-Type content = "text/html;
charset = windows-1251">
<11> J a v a S c r i p t ActionScript</TITLE>
</HEAD>
<BODY BGCOLOR = "#e0e0eO">
<! Flash- >
<OBJECT CLASSID = "clsid:D27CDB6E-AE6D-llcf-96B8-444553540000"
CODEBASE = "http://download.macromedi a.com/pub/shoekwave/cabs/flash/
swflash.cab#version =
6,6,0,0" WIDTH = "400" HEIGHT = "100" id =
"myflash" ALIGN = "">
&
276
4.
4.30 ()
5.
Windows
,
, (, , ). JavaScript
.
,
JavaScript VBScript, Windows FileSystemObject
(FSO ). JavaScript VBScript, , IE5+, Windows Scripting Host (WSH), Windows 98 SE ( Windows Based Script Host).
, ,
.
.
. ,
.
FSO , ( Active Server Pages, ASP). WSH, , FSO : JavaScript js
Windows ( wscript.exe,
Windows). () js.
MS DOS
cscript.exe.
, (, Norton
AntiVirus) .
, , , (, , .).
JavaScript, WSH, . . , -
278
5. Windows
5.1.
, ,
FileSystemObject ( , FSO).
JavaScript HTML-,
FSO :
v a r fso = new A c t i v e X O b j e c t ( " S c r i p t i n g . F i l e S y s t e m O b j e c t )
WSH, :
var fso = W S c r i p t . C r e a t e O b j e c t ( " S c r i p t i n g . F i l e S y s t e m O b j e c t " )
fso ( ),
.
. FSO, ,
WSH. , FSO ActiveX, Wscript.
.
,
, , , . , , . . . :
(FSO) :
v a r fso = new A c t i v e X O b j e c t ( " S c r i p t i n g . F i l e S y s t e m O b j e c t " )
:
var x = fso.()
, :
var = .()
v a r z = .()
, :
var fso = A c t i v e X O b j e c t C ' S c r i p t i n g . F i l e S y s t e m O b j e c t " ) // FSO
ar d = f s o . G e t D r i v e ( " C " )
/*
*/
var freespace = d.FreeSpace //
Wscript.Echo(freespace)
//
5.2.
279
. , FSO : Get-
Create-. Get,
Create. Get- (get ). Create- (create ). . Create-,
, , Create- , Get-. , ,
, . : Get- , Create-,
, ,
Get-.
5.2.
( , , . .). , , ,
. , ,
. ,
, , . , , .
FSO ,
, fso.
. dpath ,
, - ,
. fso.GetDrive(path) ,
, dpath. d. ,
. , d.IsReady true,
, false . d.FreeSpace
. ,
dpath , fso.DriveExists(dpath).
0, , 1.
driveinfo(dpath), , :
function d r i v e l n f o ( d p a t h ) {
//
//
var fso = A c t i v e X O b j e c t ( " S c r i p t i n g . F i l e S y s t e m O b j e c t " )
var disk = fso.GetDriveName (dpath)
// ()
v a r dinfo = new A r r a y ( 7 )
if (fso.DriveExists(disk)) {
//
5. Windows
280
//
//
//
//
//
//
//
//
*/
,
(, ). var disk = fso.GetDriveName(dpath) ,
, .
driveinfo(dpath), :
function dri velnfo(dpath) {
. . .
//
WScript.Echo(driveInfo("A"))
WScript.Echo(driveInfo("C"))
WScript.Echo(driveInfo("D") )
WScript .Echo(driveInfo("E") )
WScript.Echo(driveInfo("C: \\ ") )
var x = dri ve!nfo("C")
WScript . Echo( ": " + x[5])
js (
).
driveTotallnfo(dpath) ( . . 5.1),
5.1, , . ,
. , .
5.1. driveTotallnfo(dpath)
function driveTotaUnfo(dpath) {
//
var fso = new Acti v e X O b j e c t ( " S c r i p t i n g . Fi l e S y s t e m O b j e c t " )
var di sk
if (Idpath)
disk = new Array ( "" , "" , "" , "D" , " " , "F"
else
disk = new Array (fso. GetDri veName(dpath) )
var s = "", t, d
ford = 0; i < d i s k . length: i++){
if (f s o . D r i v e E x i s t s ( d i s k [ i ] ) ) {
d = fso.GetDrive(disk[i] )
s w i t c h (d.DriveType) {
/* ,
*/
"Z")
//
//
//
//
5.2.
case
case
case
case
case
1:
2:
3:
4:
5:
t
t
t
t
t
281
= "
='"
= "
= "
= "
- "; break
"; break
- " ; break
- C D - R O M " ; break
" ; break
//
if (d.IsReady){
s+= d .VolumeName + t
s+= "\n SN: " + d.SerialNumber
s+= "\n : " + d.TotalSize
s+= "\n : " + d.FreeSpace
}else
s+= t+ " "
s+= "\n\n"
//
//
//
//
//
!
WScript.Echo(s)
/*
*/
driveTotallnfo(dpath) , '
, WScript.Echo(s) alert(s).
:
I
14=
1075
: 31":
;
3N:2^170,
: 1C'
: >
SN: 99359:
SN: 56344!
: 10'
. 5.1. driveTotal!nfo()
282
5. Windows
5.3.
.
5.3.1.
:
v a r fso = new A c t i v e X O b j e c t ( " S c r i p t i n g . F i l e S y s t e m O b j e c t " )
fso.CreateFolder(folderpath)
/*
,
*/
5.3.
283
5.3.2. ,
, .
CopyFolder(foLderpathl, folderpathZ [, ]) ,
folderpathl, , folderpath2; true,
folderpathZ .
MoveFolder(folderpathl, folderpathZ) ,
folderpathl, , folderpathZ.
DeleteFolder(folderpath [, force]) , folderpath;
true, , .
284
5. Windows
if ( f s o . G e t D r i v e ( d i s k ) . D r i v e T y p e == 0 || f s o . G e t D r i v e ( d i s k ) . D r i v e T y p e ==
4)
return -1
fso.DeleteFolder(folderpath)
//
return fso.FolderExists(folderpath) /*
*/
}
.
5.4.
, ,
, .
5.4.1.
, :
v a r fso = new A c t i v e X O b j e c t ( " S c r i p t i n g . F i l e S y s t e m O b j e c t " )
f so. Crea telex tFUe(fUepath)
, , . , 5.4.3.
. ,
txt. htm, html,
shtml, js, asp, prg . , .
, .
, , CreateTextFileQ . -
5.4.
285
, , ,
-. 5.3
createFue(filepath), . , , filepath, .
5.3. createFile(filepath)
function createFile(filepath){
//
/* 0, */
var fso = new ActiveXObject("Scripting.FileSystemObject")
var i = filepath.lastlndexOf("\\")
if (i >= 0) file = filepath.substr(i + 1) /*
filepath */
var folder = filepath . slice(0,i)
/*
*/
if (!createFolder(folder)) return 0
/*
*/
if (fso.FileExists(file))
// ,
return fso.OpenTextFile(filepath , 2) //
return fso.CreateTextFile(folder + "\\" + file)
/*
*/
}
createFolderQ , 5.3.1. . , filepath
, .
createFHe(filepath)
filepath JavaScript:
lastlndexOfQ, substrQ slice().
:
GetBaseName(filepath) filepath ;
GetExtensionName(filepath)
filepath.
, , . , CloseQ.
// :
var fso = new ActiveXObject("Scripting.FileSystemObject")
v a r myfile = fso.CreateTextFile(":\\ oye\\testfile.txt")
286
5. Windows
var myfile.Close()
// :
var fso = new ActiveXObject("Scripting.FileSystemObject")
var f = fso.OpenTextFile("C:\\ \\11lie.txt ", 2)
var myfile.CloseO
// / :
var myfile = createFile("C:\\ \\11ile.txt ")
var myfile.Close()
5.4.2. ,
, ()
(FSO) .
v a r fso = new A c t i v e X O b j e c t ( " S c r i p t i n g . F i l e S y s t e m O b j e c t " ) // FSO
var file = f s o . G e t F i l e ( f i l e p a t h l )
//
/* filepathl f i l e p a t h 2 */
file.Copy(fiIepath2)
fso.CopyFile(filepathl.fiIepath2)
/* filepathl f i l e p a t h 2 */
file.Move(filepath2)
fso.MoveFile(filepathl.fiIepath2)
/* filepathl */
file.Delete(filepathl)
fso.DeleteFile(filepathl)
,
. , true ,
, . ,
.
testfile.txt :\ , C:\Windows\Temp . .
v a r fso = new A c t i v e X O b j e c t ( " S c r i p t i n g . F i l e S y s t e m O b j e c t " )
v a r fl = f s o . C r e a t e T e x t F i l e ( " C : \ \ o y e \ \ t e s t f i l e . t x t " )
fl.CloseO
//
fl = f s o . G e t F i l e ( " C : \ \ M o n flOKyM6HTbi\\testf i le . t x t " ) /*
*/
f l . M o v e C ' C : \ \ W i n d o w s \ \ T e m p \ \ t e s t f i l e . t x t " ) /*
C:\Windows\Temp */
v a r f 2 = f s o . G e t F i l e ( " C : \ \ W i n d o w s \ \ T e m p \ \ t e s t f i l e . t x t " ) / /
f2.Copy ( " C : \ U e s t f i l e . t x t " )
/*
: \ */
/* : */
fl = fso.GetFile("C:\\Windows\\Temp\\testfile. txt")
f2 = fso.GetFile("C:\\testfile.txt")
fl.DeleteO
//
C:\Windows\Temp\testfile.txt
f3.Delete()
/*
C:\testfile.txt */
5.4.
287
, .
, CloseQ.
, , . , , , , , .
, , .
. ,
. (. 5.3).
, .
() Size
. C:\autoexec.bat:
var fso = new A c t i v e X O b j e c t ( " S c r i p t i n g . F i l e S y s t e m O b j e c t " )
var fl = f s o . G e t F i l e ( " C : \ \ a u t o e x e c . b a t " )
//
var size = fl.Size
//
:\autoexec.bat
WScript.Echo(size)
/*
*/
Size
FreeSpace , , .
5.4.3.
, , ,
. :
;
;
.
OpenTextFile
FileSystemObject OpenAsTextStream .
: (for reading only),
(for writing) (for appending) .
. . ,
, .
:
v a r fso = new A c t i v e X O b j e c t ( " S c r i p t i n g . F i l e S y s t e m O b j e c t " )
var myfile = f s o . O p e n T e x t F i l e ( f i l e p a t h , mode)
288
5. Windows
:
(_) (), ;
ReadLineQ ,
;
ReadAUQ .
Read(KC^M4ecTBO_6aPiTOB) ReadlineQ ,
5)<1'(_) ScipLineQ .
,
Column ( ) Line ( ) . , , 1. ReadLineQ SkipLineQ Line 1.
, ReadAU() ,
.
:
5.4.
289
Write () ;
WriteLine(cTpOKa)
;
WriteBlankLines(K(WM4ecTBo) , ; ,
.
5.4 .
5.4.
var filepath = " : \ \ \\151ile.htm"
v a r fso = new A c t i v e X O b j e c t ( " S c r i p t i n g . F i l e S y s t e m O b j e c t " )
var myfile = f s o . C r e a t e T e x t F i l e ( f i l e p a t h , true) //
myf11e.WriteLine("<html>")
myfile.WriteLine("<hl>npHBeT ! < / > " )
m y f i l e . W r i t e L i n e ( " - ")
myfile.Write("<script>alert('- ')</script>")
myfile.WriteBlankLines(2)
//
myfile.CloseO
//
var fso = new A c t i v e X O b j e c t ( " S c r i p t i n g . F i l e S y s t e m O b j e c t " )
var myfile = f s o . O p e n T e x t F i l e ( f i l e p a t h , 8 )
/*
*/
myfile.Write("</html>")
//
myfile.CloseO
//
var fso = new A c t i v e X O b j e c t ( " S c r i p t i n g . F i l e S y s t e m O b j e c t " )
var myfile = fso.OpenTextFile(filepath,1)
//
myfile.Read(6)
// : "<html>"
myfile.SkipLineO
//
var x = myf i le. ReadLineO
/* :
"<> BceM!</hl> */
myfile.CloseO
//
WScript.EchoQ. , WScript.Echo(myfile.Readl_ine()).
, . 5.5 , .
5.5. ,
function FileToArray(filepath){
//
var fso = new A c t i v e X O b j e c t ( " S c r i p t i n g . F i l e S y s t e m O b j e c t " )
var file = f s o . G e t F i l e ( f i l e p a t h )
var size = f i l e . S i z e
//
file = fso,OpenTextFile(filepath)
file.Skip(size)
//
v a r lines = file.Line-1
//
file.Closet)
var fso = new A c t i v e X O b j e c t ( " S c r i p t i n g . F i l e S y s t e m O b j e c t " )
var file = fso.OpenTextFile(filepath)
var x = new A r r a y O
&
290
5. Windows
5.5 ()
var i = 0
i++
}
//
file.CloseO
return x
//
}
, :
WScript.Echo(FileToArray(":\\autoexec.bat"))
, FileToArrayQ
FSO . , ,
. , , ,
1 , Line. , .
, .
5.4.4.
() Ink, , .
.
url URL- (-). , , , Wscript.Shell,
WSH. (, )
, , FSO.
SpecialFoldersQ
, , , , ,
. ().
, Desktop,
MyDocuments, Favorites. : AUUsersDesktop, AUUsersStartMenu, AUUsersPrograms,
AUUsersStartup, Desktop, Favorites, Fonts, MyDocuments, NetHood, PrintHood, Programs,
Recent, SendTo, StartMenu, Startup, Templates.
, ,
, :
var Myshell = new A c t i v e X O b j e c t ( " W S c r i p t . S h e l l " )
var mypath = M y s h e l l . S p e c i a l F o l d e r s ( " S t a r t M e n u " )
/* : C : \ W i n d o w s \ r n a B H o e */
5.4.
291
(url-)
- :
var Myshell = new A c t i v e X O b j e c t ( " W S c r i p t . S h e l l " )
v a r mypath = M y s h e l l . S p e c i a l F o l d e r s ( " F a v o r i t e s " )
var myshortcut = Myshell.CreateShortcut(mypath +
" \ \ W e b - . u r l " )
m y s h o r t c u t . T a r g e t P a t h = M y s h e l l . E x p a n d E n v i ronmentStringsC'http: / /
www.admiral.ru/~dunaev")
myshortcut. SaveO
,
TargetPath ( ) URL- .
292
5. Windows
5.4.5.
Run() Wscript.Shell. ( ) .
5.5.
Windows ,
, , ,
. ,
.
Windows . . Windows 3.1
(Windows for WorkGroups) reg.dat Windows.
, Windows 9x/Me . ., , Windows: system.dat user.dat.
ini-. . ini- Windows,
.
, .
(), () (. 5.1).
5.1.
HKEY_CLASSES_ROOT
HKCR
, OLE .
HKEY CURRENT_USER
HKCU
Windows ,
Windows. ,
, .
Windows,
HKEY_USERS\DEFAULT
HKEY_LOCAL_MACHINE
HKLM
293
5.5.
HKEY USERS
HKU
Windows .
HKEY_CURRENT_USER.
,
HKEY_CURRENT_USER
HKEY_USER
HKCC
Plug&Play,
HHEY DYN_DATA
HKDD
,
.
> > >
.
Windows,
, . .
. . , . , ,
- . .
system.dat user.dat
.
, , . , ,
.
.
regedit.exe. , > , regedit . .
reg-. , . reg-, ,
Windows
.
reg- .
294
5. Windows
. . .
"_1"=^
[_2]
"_21"=21
"_22"=22
'
"_2"=2
[_1_]
"_1"=1_1
"_1_2"=1-2
"_1_"=1-
:
, ;
DWORD dword:XXXXXXXX.
X .
DWORD 0, 1.
dword:00000000, dword:00000001;
hex:XX,XX,XX,...
XX ; . , af 00 01 00
hex:af,00,01,00.
5.5.
295
, (default).
- , reg- :
(=
reg- ,
. , reg- , :
[-HKEY_LOCAL_MACHINE\Software]
, :
"_"= -
reg-,
-, Internet Explorer:
REGEDIT4
[HKEY_CURENT_USER\SOFTWARE\MirosoftXInternet Explorer\Main]
"Start Page"="http://www.myweb.ru"
, Wscript.Shell, WSH:
RegReadQ ;
RegWriteQ
;
RegDeleteQ .
:
var Myshell = new ActiveXObject("WScript.Shell")
Myshell.()
RegWrite() , , .
. , "HKEY_CURENT_
USER\\Myreg\\myparam" myparam ,
.
RegWriteQ ,
. , . , ,
,
. RegWriteQ
. ,
. , RegWriteQ "REG_DWORD" "REG_BINARY", DWORD . , .
296
5. Windows
/* HKEY_CURENT_USER\ Myreg
myparaml " ": */
Myshell.RegWrite("HKEY_CURENT_USER\\Myreg\\myparaml", "
")
/* HKEY_CURENT_USER\ Myreg
myparam2 5: */
Myshell.RegWrite("HKEY_CURENT_USER\\Myreg\\myparam2", 5, "REG_BINARY")
/* HKEY_CURENT_USER\ Myreg
DWORD 3: */
My shell. RegWrite("HKEY_CURENT_l)SER\ \Myreg\\myparam3", 3, "REG_DWORD")
RegDeleteQ , . , , , .
. , HKEY_CURENT_USER HKCU.
5.7 , ,
-.
5.7.
var Myshell = new ActiveXObject("WScript.Shell")
var mystartpage = http://www.myweb.ru //
/* , - : */
startpage = Myshell.RegWrite("HKCUX\SOFTWARE\\Microsoft\\Internet
ExplorerUMainUStart Page")
if (startpage != mystartpage)
//
Myshell.RegWrite("HKCU\\SOFTWARE\\Microsoft\\Internet
Explorer\\Main\\Start Page", mystartpage)
, .
1.
HTML
HTML (HyperText Markup Language ) -. - HTML- (HTML-), htm html. HTML, HTML- ,
. HTML (),
. ,
(, <>).
,
, . ,
, . , IMG image ().
HTML- <HTML>
</1_>. ,
. (, <1_> </HTML>). ,
. , . , , ,
. , , . , . <BR> (
).
, , , , . ( ),
, , . , , .],
<IMG 5=".jpg">
298
1. HTML
( )
HTML- : .
. , <HEAD> </HEAD>, <BODY> </BODY>. HTML- :
<HTHL>
<HEAD>
... ( )
</HEAD>
<BODY>
... ( )
</BODY>
</HTML>
,
, .
<HEAD> </HEAD>, (HTML), : <TITLE> </TITLE>. , ,
. , , : HTML. :
<HTML>
<HEAD> <TITLE> HTML </TITLE> </HEAD>
<BODY>
...
( )
</BODY>
</HTML>
HTML- .
, .
</BODY>
</HTML>
299
.htm -
?.* ,
<HIML>
<HEAD> <TITLE> HTML </TITLE> </
<BODY>
HTML .
,
| .
</BODY>
</HTML>
I
. 1.1. HTML- (Notepad)
-j
(v'''''"'1"'*-'<
HTML .
,
.
1
. 1.2. HTML- Internet Explorer
- HTML-, , ,
() HTML-. . .
> .
HTML-.
, . , .
. ,
. ,
, , .
1. HTML
300
( ), MS Word. , HTML- .
. , MS Word ( , ), HTML-, (), , ,
HTML- .
MS Word, HTML-
txt, htm html.
,
(Notepad). , MS Word, , HTML- HTML-, .
HTML, MS Word, HTML (, FrontPage) .
-, Microsoft FrontPage Macromedia Dreamweaver. . , - , .
, , , . ,
, , .
XMiciosoft FrontPage
>rmal
i|||(default font)
Uotmal
rej_pag-.> 1
HTML .
, .]
mm
. 1.3. FrontPage
301
-,
FrontPage, . FrontPage. Normal. , , . , . 1.3.
HTML, ,
, (. 1.4). HTML-
. , Normal.
<head>
<siet& http-ectuiv*"Content-Type" coriten"~"text/html; char5et=vindows-1251">
Cmeta name-"GEHERATOR" content="Hicrosof t FrontPage 4.0">
<neta name="ProgId" cor,tetit="FrontPage.Editor.Document":
<title>Heu Page K/ticle>
</head>
<body>|
<p><::span styie-"font-size: 12.Opt;font-family:"Times New Roman&cfuot;;
mso-fareast-font-family:uquot;Times Hew Romans,quot;;mso-ansi-language:RU;mso-farf
RU;mso-bidi-language: -"> HTIIL
.
,
.</:></>
</body>
</html>
,
, Preview.
FrontPage, MS Word HTML- ( <HEAD> </HEAD>) <> .
<HTML>
<HEAD>
302
1. HTML
</HEAD>
<BODY>
</BODY>
</HTML>
, <>,
. , , , , .
. <>
HTML- -, .
HTML-, ,
,
. HTML-. <!>. ,
<! >, . , - , .
,
. , , <CENTER>. , . , <CENTER> , , ,
. <CENTER> , </CENTER>.
HTML- -, . , , , , , .
. .
(
): <HEAD>, <BODY> <CENTER>.
<DIV>, ( ) HTML-.
HTML- , Java Script Visual Basic Script ( Internet Explorer).
<SCRIPT> </SCRIPT>.
, . .
, , .
HTML htm
html.
HTML- . ,
, , , (). , , .
HTML- HTML (, , . .), -
303
. ,
.
, <! >,
.
, <>, ,
. HTML- -, .
HTML- , JavaScript Visual Basic Script. <SCRIPT>
</SCRIPT>.
, .
, , .
, ,
. ,
,
, . . . , ,
, . , .
.
, (, FrontPage), ,
. , , FrontPage (. HTML).
. .
<BR> .
<> . , , . ,
,
, .
, , <CENTER>, .
<BR> <> ,
. , , , <BR> <>.
1. HTML
304
. , .
. <1>, <2>, ... <>. . , <1> </1>.
<1> 1- </1>
1- ,
.
,
. <2> , <1>, , ,
. ,
. (CSS).
(. 1.5).
- Microsoft Internet Exploiei
1-
2-
3-
4-
5-
*-
7-
.
. 1.5.
<HTHL>
<HEAD> <TITLE> HTML </TITLE></HEAD>
<BODY>
<1> 1- </1>
<2> 2- </2>
305
<> 3- </>
<4> 4- </4>
<5> 5- </5>
<6> - </6>
<7> 7- </7>
</BODY>
</HTML>
() .
(. 1.1).
1.1.
(Bold)
<B>
(Italic)
(Underscore)
<I>
<U>
(Strike Out)
(Typewriter)
( Netscape Navigator)
<S>
<TT>
<BLINK>
, , . , <> </>.
(. 1.6):
<1_>
<><11> </11></>
<BODY>
<><></>
<1><></1>
<><></>
<5><></5>
<> <></>
<><1> <>
<11>
</BODY>
</HTML>
, (. 1.7). ,
, , :
<1_>
<><11_> </11_></>
306
1. HTML
* Microsoft Internet Explorer;
1
.""'',
. -Q. | I
0<I8HCBHTh
OftHOBIHb
.1.-11.
1~11_
i din
1
1
. 1.6.
*| - Microsoft Internet Exploiei
Jrt
- |
|
-. 2-
_J
. 1.7.
<BODY>
307
.
+ ( ) -( ). , 3,
<FONT SIZE=+2> 5.
<FONT ="_">.
HTML-, , . , .
,
, ,
. <FONT> .
.
.
. ,
. ,
. ,
, .
COLOR <FONT> :
<FONT 01(="">
COLOR
(, , , , RGB-). (. 1.8).:
- Miciosoit Internet Exploit*
Anal
Courier
SYMBOL
. 1.8.
1. HTML
308
<HTML>
<><11_> </TITLE></AD>
<BODY>
<> AriaKFONT FACE="ARIAL">ABEK </FONT>
<> C o u r i e r < F O N T = "011> < / F O N T >
<> SYMBOL<FONT F A C E = " S Y M B O L " SIZE=7 010=""> </FONT>
</BODY>
</HTML>
, <FONT>
.
,+ ,+ .
] ( '>
. 1.9.
, :
<ADDRES> , ;
309
<1> ;
<CODE>, <SAMP> , ;
<KBD> .
( Courier).
, I ,
. .
. ,
, 11="", . TITLE .
. ,
.
, : , . - ,
. , . <BODY>.
BGCOLOR <BODY>. , , "#FF1230", :
<BODY BGCOLOR="#FF1230">
:
<BODY BGCOLOR="YELLOW">
. TEXT <BODY>. , , :
<BODY BGCOLOR="GREEN" TEXT="BLUE">
,
. .
1.2.
BLACK
#000000
NAVY
#000089
SILVER
'
BLUE
#OOOOFF
MAROON
#800000
PURPLE
#800080
1. HTML
310
1.2 ()
RED
#FFOOOO
FUCHSIA
GREEN
TEAL
LIME
AQUA
#FFOOFF
#008000
#008080
#OOFFOO
#OOFFFF
OLIVE
GREY
YELLOW
WHITE
#808000
#808080
#FFFFOO
#FFFFFF
HTML- ,
, .
, , HTML-, <PRE>.
<PRE> </PRE>.
( ).
( ). .
, .
<OL>, <UL>.
, .
. TYPE : 1 ( ), ( ),
( ), I ( ). , . START
<OL>.
<LI>, . TYPE.
1.1 , (. 1.10).
1.1.
<HTML>
<><11>< /TITLE ></HEAD>
<BODY>
311
- Microsoft Internet Explorer
(.
11
- . - 5
5.
6.
7.
8.
- .
i.
ii.
iii.
iv.
- .
. 1.10.
<2></2>
<> - . - 5<BR>
<OL TYPE=1 START=5>
<1>
<1>
<1>
<11>
</OL>
<> - . <BR>
<OL TYPE=i>
<11>
<1>
<1_1>
<1>
</OL>
<> - . <BR>
<UL>
<11>
<11>
<11>
1. HTML
312
<1_1>
</UL>
</BODY>
</HTML>
, , . , . <HR>,
:
SIZE ;
WIDTH ;
ALIGN ( CENTER, LEFT RIGHT);
, NOSHADE .
(. 1.11).
. - Microsoft Internet xplorr
(>[
.
.
- ,
. - 5
- 10 200
- 5,
NOSHADE
| our.
. 1.11.
313
<HTML>
<BODY BGCOLOR="#E0E0E0">
<1> <1>
<>
. HR.<BR>
- ,
<HR>
. 5
<HR SIZE=5>
<> - 10 200
<HR SIZE=10 WIDTH=200>
<> - 5, N05HADE
< H R SIZE=5 NOSHADE>
<>
</BODY>
</HTML>
, ,
.
.
Internet Explorer <MARQUEE>,
,
. :
WIDTH
;
HEIGHT ( );
HSPACE, VSPACE ( );
ALIGN ;
:
Q ();
BOTTOM ();
MIDDLE ();
DIRECTION ; :
Q LEFT ( );
Q RIGHT ( );
BEHAVIOR ; :
Q SCROLL ;
SLIDE ;
Q ALTERNATE , , ;
314
1. HTML
LOOP , ;
, INFINITY. LOOP
, BEHAVIOR ALTERNATE
SLIDE;
SCROLLAMOUNT ;
, ;
SCROLLDELAY ;
BGCOLOR , .
, ,
, .
75% (. 1.12).
- Microsoft Internet Eaploret - ! F
O$J>BIIC
" "
> :
. 1.12.
<HTML>
<><11> </11></>
<BODY>
" "
<MARQUEE HEIGHT=50 WIDTH=75% HSPACE=5 VSPACE=5 ALIGN=TOP BGCOLOR=YELLOW
DIRECTION=LEFT LOOP=INFINITE BEHAVIOR=SCROLL 5CROLLAMOUNT=5
SCROLLDELAY=100>
<H1> </1>
</MARQUEE>
</BODY>
</HTML>
HTML- , . , -
315
< > ,
. ( ") (&) HTML . , ,
, Shift,
HTML-, .
ASCII. .
:
&_;
, < < (less then, ).
:
&#_5;
, < <.
, & . ASCII- #. . 1.13
.
HTML-. 1.2
.
1.2.
<HTML>
<HEAD><TITLE /TITLE></HEAD>
<2>
<SAMP>
. <(?>
<HR>
"    34 quote<BR>
&    38 amp<BR>
<    60 U<BR>
>    62 gt<BR>
    160 nbsp<BR>
¢   162 cent<BR>
£   163 pound<BR>
§   167 sect<BR>
©   169 copy<BR>
®   174 reg<BR>
±   177 piusmn<BR>
µ   181 micro<BR>
¶   182 para<BR>
¼   188 frac!4<BR>
½   189 frac!2<BR>
¾   190 frac34<BR>
Æ   198 AElig<BR>
Ø   216 Oslash<BR>
æ   230 aelig<BR>
1. HTML
316
&
<
>
<:
u
1
E
0
*
-5-
34
38
60
62
160
162
163
167
169
174
177
181
182
188
189
190
198
216
230
247
quote
amp
It
gt
nbsp
cent
pound
sect
copy
reg
plusmn
micro
para
frac!4
frac!2
frac34
AElig
Oslash
aelig
divide
. 1.13.
<SAMP> , .
 () ,
, ,
.
-
- . . , .
317
<IMG> ( , image )
SRC:
<IMG 5="__">
URL-, , ,
.
, logotip.jpg
<IMG S R C = " l o g o t i p . j p g " >
<IMG> ( ) LOWSRC,
. :
(, logotip.jpg) ,
, (, Logotip.gif) ,
.
<IMG SRC="logotip. jpg" LOWSRC="logotip.gif">
logotip.gif,
logotip.jpg.
WIDTH () HEIGHT (),
. , , , . , ,
. :
<IMG SRC="logotip.gif" WIDTH=40 HEIGHT=20>
WIDTH , , a HEIGHT .
, . ALIGN
<IMG> . , ,
. , . ,
.
VSPACE HSPACE <IMG>.
,
. <BR
CLEAR=...>.
318
1. HTML
logotip.jpg ( ):
. <IMG SRC="logotip.]'Pg" ALIGN=LEFT>
, ALIGN RIGHT:
<IMG S R C = " l o g o t i p . j P g " A L I G N = R I G H T >
, :
< I M G S R C = " l o g o t i p . j p g " A L I G N = L E F T HSPACE=20 VSPACE=10>
20 10 .
.
( Notepad). HTML- . ,
(. 1.14). .
logotip.gif.
<21 1 - Microsoft Internet Exploter
-
.
HTML
.
.
. ,
.
.
, .
!
. 1.14.
<HTML>
<HEAD> <TITLE> 1 </TITLE>
</HEAD>
<BODY BGCOLOR="YELLOW">
319
,
. , ( ), , .
(, ).
<BODY> HTML-,
. BACKGROUND,
. ,
fon.gif, :
<BODY BACKGROUND="fon.gif">
Internet Explorer
BGPROPERTIES=FIXED, . :
<BODY BACKGROUND="fon.gif" B G P R O P E R T I E S = F I X E D >
, , ,
, , .
,
. ALT <IMG>.
gif 18K]">
320
1. HTML
( )
. . .
. ,
.
HTML .
< HREF>, </>.
, ,
, .
:
, .
:
< = " _ " > _ < / >
, </>.
, HTML- 2.1:,
:
<. HREF="4OKyM2.htin"> </>
, , , ,
> <. , , , .
:
< ^="_"> <IMG 5(?="__"> </>
, HTML- 2.1,
logotip.gif:
< HREF="flOKyM2.htm"> <IMG S R C = " l o g o t i p . g i f " > < / A >
321
, :
< H R E F = " f l O K y M 2 . h t m " > <IMG S R C = " l o g o t i p . g i f " > < / A >
. .
, , . , , .
: , . , ,
, , . , , , ,
. .
. .
.
<> () NAME . . <> </> <AREA>
() . <AREA> , , :
HREF , ;
SHAPE ; :
Q "RECT" ();
Q "POLYGONE" ();
Q "CIRCLE" ();
COORDS , , ; (
; ; ).
</> ,
, <IMG>,
:
$="#_"
NAME <>.
. , .
.htm .htm, , , .
<1_>
<><11_> </TITLE></HEAD>
322
1. HTML
< NAME="map0">
<AREA HREF = "ceBepHbiti.htm" SHAPE="RECT" COORDS = "150 ,100 ,250, 250">
<AREA HREF=".htm" SHAPE="CIRCLE" COORDS="150,380,50">
</MAP>
<IMG SRC="Kapia.jpg" USEMAP="#map0" WIDTH=360 HEIGHT=480>
</HTML>
,
, (, Adobe Photoshop),
, . .
, , . -, FrontPage.
URL-
. URL- (Uniform Resource Locator ). URL-
( ), , .
URL (. 1.3).
1.3. URL
URL-
http://
FTP
ftp://
mailto:
Gopher
Gopher://
UseNet
news:
323
.
mailto, , .
Gopher ( , ), , ,
. , .
News ; , , .
URL-:
< HREF="f tp: / / f tp.admi rat. r u / P U B / i n d e x . "> < / >
<A H R E F = " m a i l t o : d u n a e v @ m a i I . a d m i r a l . " > 0 < / >
.
, . () , .
() . , myfile.htm, , .
, . ../ (,. ./myfile.htm),
, , , . , ../../ (,
../. ./myfHe.htm), ,
.
( , ),
(). ,
( ). (). , HTML-, ,
- (, MS Word, MS Excel), .txt. ,
.. ( ,
Internet Explorer) . : .
, . ,
,
, .
. , -
1. HTML
324
HTML-. ,
.
HTML-,
. .
: . , .
() .
:
< ="_"> __</>
:
< "#_"> ___</>
> - Microsoft Internet Enplotei
>
?
. ,
.
'!. HTML
2.
!. HTML
HTML.
HTML , .
(. 2)
2.
,
]... .
. 1.15.
1.3. ,
(. 1.15).
,
.
325
1.3. ,
<1_>
<><11_> </11_></>
<>
.
,
.
<>
<2></2>
< > < > < ="#1">1. HTML</A>
<BR><A = "#2">2 . </>
<2>< ="1">1 ,</> HTML</H2>.
HTML.
HTML ,
.
(< ="#2">. 2</>) .
<>
<2>< = " 2 " > 2 . </> </2>
,
< ="#1">1 . < / >
.
</BODY>
</HTML>
- . -.
, HTML- ().
, .
.
() , , ,
. , .
. , ,
.
HTML-. , () (). . , .
: , . , , -
326
1. HTML
.
( ).
HTML- <TABLE> </1>. , (), BORDER, :
<TABLE BORDER>
BORDER (), , :
<TABLE
BORDER=10>
<TR> </TR>.
,
<> </>. ,
<TD> </TD>.
<TR> </TR>.
, ( <TABLE>), ( <TR>) ( <TD> , <> ).
, .
. , .
, , . , .
, <TR> <>, <TD>.
<HTML>
<><11_></11_></>
<BODY>
<2> </2>
<>
(. 1.16).
<>
<TABLE BORDER>
<CAPTION ALIGN=TOP>CnHCOK </>
<TR>
<></><></><></>
</TR>
<TR>
<></><></><>100</>
</TR>
<TR>
<></><></><>800</>
</TR>
<TR>
<></><></><>50</>
327
</TR>
</TABLE>
</BODY>
</HTML>
3 - Miciosoft Internet Explocer
Cgpiwc
'
| ^ |
>
[ [
[
1000
|50
I
.
. 1.16.
, . , ,
. , . COLSPAN ROWSPAN ( ).
. :
<HTML>
<><11_></11></>
<BODY>
<2> </2>
<>
(. 1.17).
<>
<TABLE BORDEFO
<CAPTION 1=> </>
<TR><TH 015=2> </><></>
</TR>
<TR><TD>MBaH</TD><TD>4HpeKTOp</TD><TD>1000</TD>
</TR>
<TR><TD>rieTp</TD><TD>ByxranTep</TD><TD>800</TD>
</TR>
<><></>< ROWSPAN=2>Pa6o4iifi</TD><TD>50</TD>
</TR>
1. HTML
328
<(*><></><>70</>
</TR>
</TABLE>
</BODY>
</HTML>
- Microsoft Internet Explwe
.
(.{
[ J1000
^ 1800
!
, J50~
I
[
[!
[70
. 1.17.
, .
,
. : . ,
, . WIDTH <1_>,
<> <TD>.
<HTML>
<><11></11></>
<BODY>
<2> </2>
<>
(. 1.18).
<>
<TABLE BORDER WIDTH=400>
<CAPTION 1=> </>
<TR>
<TH COLSPAN=2 =75%> </> <></>
</TR>
329
<TR>
<></><></><>1000</>
</TR>
<TR>
<></><></><>800</>
</TR>
<TR>
<></>< ROWSPAN=2>Pa6o4Mii</TD><TD>50</TD>
</TR>
<TR>
<></><>70</>
</TR>
</TABLE>
</BODY>
</HTML>
- Microsoft Internet Explore!
tgjjBUr,
. .
OcjaiioHiiib
Qi\..
1
I
1800
|50
|70
. 1.18.
. ALIGN
<TR>. ALIGN
<> <TD>. ALIGN LEFT ( ),
RIGHT ( ) CENTER ( ).
ALIGN:
<TR A L I G N = L E F T >
330
1. HTML
BOX ;
ABOVE ;
BELOW ;
.
HSIDES ;
VSIDES ;
LHS ;
RHS ;
VOID .
RULES <TABLE>. RULES , :
A L L ;
ROWS ;
f| - Miciosofl Internet Explorer
[{
"
i ! U'1C>5<!
. 1.19.
*!
331
COLS ;
NONE .
1.4 (. 1.19).
1.4.
<1_>
<><11_>< /TITLE > < / H E A D >
<BODY>
<2> < / 2 >
<>
<>
. , 1000, (. 1.20).
.
,
332
1. HTML
- Microsoft Internet Enploier
|
|
| ,3
1000
. 1.20.
. ,
, . ,
, : , .
HTML , . , - .
.
<HTML>
<><11></11><>
<BODY>
<2>
</2>
<TABLE>
<TR>
333
</TABLE>
</BODY>
</HTML>
BGCOLOR,
. , BGCOLOR <TABLE>. <TR>.
BGCOLOR <TD>.
, :
BORDERCOLOR - ;
BORDERCOLORLIGHT - ;
BORDERCOLORDARK - .
<TABLE>. , BORDER, . :
<TABLE BGCOLOR="#F0F0F0" BORDER=10 BORDERCOLOR="#808080"
BORDERCOLORLIGHT="#707070" BORDERCOLORDARK="#202020">
<TR BGCOLOR="BLUE">
<></><></>
</TR>
<TR>
<TD BGCOLOR="YELLOW">MBaH</TD><TD>r.-</0>
</TR>
</TABLE>
<TD>:
<TD B G C O L O R = " Y E L L O W " > < H 2 > M B a H < / H 2 > < / T D >
, . , , FrontPage
Dreamweaver. .
Dreamweaver , FrontPage.
, .
. . . ,
<Hl>, <FACE> . .
( Cascading Style Sheets CSS) , . <STYLE>, STYLE.
334
1. HTML
, (, ), . , , ,
. ,
.
.
, , . ,
, .
,
. HTML-
.
<STYLE> </STYLE> <HEAD>
</HEAD>, STYLE (<1>, <2>,..., <6>), <BODY>, <DIV> .
<STYLE>:
<HEAD>
<STYLE>
{!:! ; 2 : 2 ,
}
</STYI_E>
</HEAD>
. . . , :
, .
, ,
.
STYLE:
<HTML>
<HEAD>
<STYLE>
HI {Font-size:48pt;Color:RED}
H2 {Font-size:20pt;Color:BLUE}
</5TYLE>
</HEAD>
<BODY>
<>
-
</BODY>
</HTML>
HI 2, :
(48 30 ) ( ) ,
. . , FONTFAMILY: HELVETICA HELVETICA.
, <STYLE> , .
335
. 1.21.
336
1. HTML
, .
, .
, 1_5$=_.,
.
, :
<STYLE>
mystyle {color:black;font-family:Arial}
</5TYLE>
-
:
<2 CLASS=mystyle>
( 1.5), , (. 1.21). .
( SD-). , ( ) . <DIV>
HTML-. , BODY : , , !
2. .
i
1.5.
<1_>
<HEAD>
<11> CSS</TITLE>
<STILE>
BODY {color: black; font-size:16px; font-family: Arial}
. {color: #DBDBDB; text-align:right; weight: medium; margin-top:
30px; font-size:270px;line-height: 270px;
font-family: Times}
. {color: red; weight: 900; margin-top: -230px; font-size:220px;
line-height: 250px; font-family: Times}
.! {color: black; margin-top: -130px; weight: medium; ont-size:65px;
line-height: 65px; font-family: Arial}
.2 {color: green; margin-top: 30px; weight: medium; font-size: 35px;
line-height: 45px; font-family: Arial}
</STYLE>
</HEAD>
<BODY>
<CENTER>
<TABLE WIDTH=500 CELLPADING=0 CELLSPACING=0 BORDER=0>
<TR>
<TD ALIGN=CENTER VALIGN=TOP>
<DIV 155=></01>
<DIV CLASS=ocHOBa>Mbi</DIV>
<DIV 155=1> </01>
<DIV 1_55=2> </01>
</TD></TR>
</TABLE>
</CENTER>
337
</BODY>
</HTML>
<DIV> CLASS.
<DIV> ( ).
, , . CLASS
,
<DIV CLASS.. .> </DIV>. , : , .
CLASS . : -, .
,
. , ,
, ! 2. ,
, , <DIV>.
margin-top ( ).
:
margin-top ;
color ;
font-size ;
font-family ;
weight ;
line-height .
margin-top,
.
STYLE, , <>, <>, <DIV> <IMG>.
:
51="__"
, ,
<STYLE>.
STYLE ,
. STYLE :
<2 S T Y L E = " f o n t - s i z e : 4 8 : font-family:Ari1"> < / 2 >
, . .
:
338
1.
HTML
left (-);
top (-);
z-index ,
; , z- z-.
, , , .
2,5- .
- position, left top
. position .
absolute Left top (, ). ,
. ,
HTML-.
relative , ; . ,
, , relative, left top .
left top .
static
.
z-index.
,
(. 1.22).
, z-index
HTML-.
<HTML>
<><11>< /TITLE ></ AD>
<BODY BGCOLOR="AQUA">
<DIV STYLE= "position: absolute; top :0; left : 70; width : 50; height : 100 ;zindex :2">
<IMG SRC="logotip.gi f ">
<DIV STYLE=" posit ion: absolute; top : 10; let t: 15 ; width ; 400; height : 100 ">
<H1 STYLE="color : "> ,
</1>
<DIV STYLE= "positi on: absolute; top : 60; left : 300; wi dth : 50; height : 100" >
<H1 5TYLE="color :"> </1>
</BODY>
</HTML>
339
.(
j ^ "1111111
. 1.22.
, ( ,
<DIV>). , . overflow ().
overflow :
() (
), ;
clip ;
scroll .
overflow
(. 1.23):
<HTML>
<><11></11_></>
<BODY BGCOLOR="AQUA">
<DIV STYLE=" position : absolute; top: 0; let t : 70; width : 50; height : 100" >
<IMG SRC="logotip.gif">
<DIV S T Y L E = " p o s i t i o n : a b s o l u t e ;
top: 10; left: 15; width: 220; height: 120;overf low: scroll ">
<H1 STYLE="color : !"> ,
</1>
<DIV S T Y L E = " posit ion: absolute; top: 60; left: 300 ;width: 50; height: 100 ">
<H1 STYLE="color :"> </1>
</BODY>
</HTML>
1. HTML
340
. 1.23. overflow
, - , , , .
, -.
. , , . ,
(). . , .
, .
.
, :
f i l t e r : _
, , :
f i l t e r : _(!,2,....)
HTML ( 4) 14 .
, :
blur ;
fliph ;
341
flipv ;
wave ;
-,
( ).
,
, flipv, fliph blur.
. 1.24. flipv
, f l i p h ,
blur . , blur,
, , .
[ - Microsoft Internet Explorer
.: .; .'> ..
_d
y
|
i
|
-J?
;j
-LJ
Hiopatmo
rfqift
. 1.24. flipv, fliph blur
<HTHL>
<><11_></11_></>
<STYLE>
{position:absolute;top:0;left:190;font-size:80}
</5TYLE>
<BODY>
--
342
1. HTML
:1111?.|1
_*]
^'1
Wave
t:]'1"^
. 1.25. wave
<HTML>
<><11></TITLE></HEAD>
<STYLE>
{position:absolute;top:0;left:190;font-size:48}
</STYLE>
<BODY>
<IMG S T Y L E = " p o s i t i o n ; a b s o l u t e ; w i d t h : 1 5 0 ; h e i g h t : 100" S R C = " w o r l d . g i f " >
343
<IMG
STYLE=" posit ion: absolute; top: 120 -.left: 10 ;w-idth: 150 ; height: 100; filter :Xray"
SRC="world.gif ">
<IMG
STYLE="position:absolute;top:230;left:10;width:150;height:100;filter:Wave"
SRC="world.gif ">
<></>
<P STYLE="top:130;filter:"> Xray</P>
<P STYLE="top:240;fHter:Wave">OnnbTp W a v e < / P >
</BODY>
</HTML>
()
. -. . ,
.
. 1.4 .
1.4.
10
11
12
13
14
15
16
17
18
19
1. HTML
344
1.4 ()
20
21
22
( 0-22)
23
. 1.26.
<HTML>
345
si
. 1.27.
346
1.
HTML
12 , . .
23
( 0 22). , , .
,
(blendtrans),
. (duration). ,
.
<1_>
Flash- -
347
<STYLE>
. , , . , . .ess.
, , , <STYLE>
</STYLE>. :
@import URL("__")
:
@import U R L ( " h t t p : / / a b c d / x y z / s t y 1 e . c s s " )
,
.
<LINK> <HEAD>. :
<HEAD>
<LINK R E L = S T Y L E S H E E T T Y P E = " t e x t / e s s " ="__"
TITLE="Style"
</HEAD>
Flash- -
Flash- SFW-, .swf,
Macromedia Flash. -
( HTML-),
HTML-. , () Flash-. Flash-
(, , , , ). , , (, ).
SWF- HTML. , Flash-
-, HTML-
.
Macromedia Flash HTML, ,
SWF-, Publish (). -. HTML- ,
.
, Flash- HTML-,
, ,
() . <> .
<> , , ,
348
1.
HTML
. <OBJECT> classid.
Flash- ( ActiveX). codebase , Flash-, . <EMBED> - Netscape-.
<PARAM>. , . <PARAM NAME=movie ="_5\^_" >
swf- Flash-. WIDTH HEIGHT
( ) , Flash-. , , .
<PARAM NAME=wmode VALUE=transparent> , . , transparent .
-.
,
Flash. Flash- STYLE. , Internet Explorer <DIV>.
Flash-, . , calculator.swf, Flash 5.0. HTML- :
<DIV style="posi t ion .-absolute ; top: 120; left : 100" >
<OBJECT class1d="clsid:D27CDB6E-AE6D-llcf-96B8-444553540000"
codebase="http: //download.macromedia.com/pub/shockwave/cabs/flash/
swf 1 as h.cab#version=6, 0 , 0 , 0 "
WIDTH="430" HEIGHT="450" id="Flashl" ALIGN="">
<PARAM NAME=movie VALUE="calculator . swf ">
<PARAM NAME=quality VALUE=high>
<PARAM NAME=scale VALUE=noborder>
<PARAM NAME=wmode VALUE=transparent>
<PARAM NAME=bgcolor VALUE=#FFFFFF>
<EMBED src="Flashl. swf " quality=high scale=noborder wmode=transparent
bgcolor=#FFFFFF WIDTH="430" HEIGHT="450" NAME="Flashl" ALIGN=""
TYPE="application/x- Shockwave- flash" PLUGINSPAGE="http: //
www.macromedia.com/go/getf lashplayer"></EMBED>
</OBJECT>
Flash
Publish () . , , HTML- .
. , Internet Explorer
(
). . Internet Explorer
WAV, AU MIDI. Internet
Explorer :
<BGSOUND SRC = "3ByKOBoi_(t)am" 1_=>
349
LOOP :
TRUE , ;
FALSE ;
.
HTML- ,
. ,
<EMBED>
() .
, Windows WAV, Macintosh AIFF. MPEG. Windows,
Macintosh Unix. QuickTime Windows Macintosh.
, , ,
,
. - , ,
.
(RealAudio). . - , .
. RealPlayer G2 RealPlayer Plus G2.
, RealAudio, RA.
, RAM.
, URL- RA.
( ) .
pnp://audio.real.com/example.ra
RealPlayer G2 ( RealPlayer Plus G2)
-, .
.
:
< HREF="ocean.qt">Cep(t)HHr, , 520</>
520,
.
Internet Explorer DYNSRC <IMG>, . , .
:
1. HTML
350
. ,
. . ,
, -. , <INPUT>
(. 1.28).
;
:
_J
. 1.28.
<INPUT> :
<INPUT T Y P E = " T E X T " >
, ( ), :
<INPUT TYPE="PASSWORD">
TYPE:
<INPUT TYPE="NUMERIC">
(radiobuttons)
351
<INPUT> :
="" , ;
\/="" ;
512="" ;
MAXLENGTH="4Mcno" ,
.
:
<INPUT TYPE="TEXT" NAME="USERTEXT" VALUE="" SIZE="20">
promptQ JavaScript, , .
. false,
.
, prompt(" ","") , . 1.29.
/
-JavaScript:
. 1.29.
(radiobuttons)
<INPUT> ,
. , TYPE="RADIO",
(radiobuttons) ,
, .
,
<UL> <INPUT> (
NAME). , CHECKED.
<INPUT> , . VALUE , ,
, -.
(. 1.30):
<HTML>
<><11></11></>
<2> ?
<UL>
1. HTML
352
?
f
<~
!
. 1.30.
( ) , . , ?
, . .
(. 1.31).
::
?
& 1 -
. 1.31.
353
<HTML>
<><11></11></>
?
<UL>
<>
<TR>
<TD>
< I N P U T TYPE = "RADIO" NAME = "LANG" VALUE="PyccKHU" >
</TD>
<TD>
<INPUT T Y P E = " R A D I O " NAME="LANG" 1.="">
</TD>
<TD>
<INPUT TYPE="RADIO" NAME="LANG" 1_ = "" >
</TD>
</TR>
</TABLE>
</UL>
</HTML>
, () (. 1.32). ,
, TYPE CHECKBOX:
<HTML>
<HEAD><TITLE> </11_></>
<2> ?
<UL>
<INPUT TYPE="CHECKBOX" NAME = "TEST" VALUE = " " CHECKED> <>
<INPUT TYPE="CHECKBOX" NAME="TEST" ) = " ">
<>
<INPUT TYPE = "CHECKBOX" NAHE = "TEST" 1. = "" >
</UL>
</H2>
</HTML>
- Microsoft Internet Exptocet
[
.'
?
I?
. 1.32.
1. HTML
354
, <TABLE>,
.
, -. , . , ,
. <BUTTON>. ,
STYLE (. 1.33).
logotip.gif :
<HTML>
.(
OOHUUllTfa
. 1.33.
, <INPUT>,
TYPE="IMAGE" 5="_", NAME VALUE:
I N P U T T Y P E = " I M A G E " 51?="_" = " _ " 1 = >
(. 1.34). , ():
<INPUT TYPE="IMAGE" SRC="arwl0ne.ico" NAME="N" 1=>
:
<INPUT T Y P E = " B U T T O N " >
355
Cg{
si-.
.>
. 1.34.
,
(CGI) ( , ). HTML-
, .
, <FORM>. .
, <FORM> , , ,
.
, . HTML. , ,
. ,
, ,
. , .
356
1. HTML
HTML-.
. () HTML- , . HTML- , , .
HTML-, , <HTML> </HTML>. <FRAMESET> </FRAMESET>. <FRAMESET>
</HEAD>, <BODY>.
.
COLS ( ) ROWS
( ). ,
. .
. , ,
(*).
. (%).
, <FRAMESET COLS="50,* ">
, 50 ,
.
<FRAMESET ROWS="20%,30%,*"> 20%, 30% 50%.
,
. <FRAMESET> ,
.
,
HTML-. , .
<FRAME>, ,
. :
SRC="MMfl_4)aMa" ="_" , NAME, HTML-, SRC.
SCROLLING , ; , YES, N0.
NORESIZE ; , .
BORDER="uiMpMHa_ncwocbi" .
BORDERCOLOR="uBeT_n(wocbi" -- ;
, .
MARGINHEIGHT="BbicoTa_BepXHero_OTcryna"
; .
MARGWIDTH="iiJMpHHa_6oKOBbix_oTCTynoB" ; .
(Internet Explorer ), <NOFRAME>
357
,
</BODY>
</NOFRAME>
</HTML>
HTML-. , ,
:
<HTML>
<><></><>
<BODY>
<2>
, 40%
</2>
</BODY>
</HTML>
<HTML>
<HEAD><TITLE>BTOpo&</TITLE><HEAD>
<BODY>
<2>
,
</2>
</BODY>
</HTML>
HTML-, ,
. 1.35.
, . , . . ,
. ,
, , . NAME <FRAME>.
358
1. HTML
- Microsoft Internet Cxpteet
,
40%
. 1.35.
:
< ="_" ="_"> _ < / >
:
< ="_" ="_"> <IMG SRC="_">
</>
.
:
new.htm, . (target
).
, , :
<FRAME S R C = . . .
NAME=...>
-.
HTML-
HTML-.
, , , . ,
. , , ,
, , , .
.
.
, , . .
, ,
. .
<>
359
<>
- , <>.
, .
, , , , , . .
<HEAD> </HEAD>.
HTML-:
<HTML>
<HEAD>
<TITLE>...<TITLE>
<! HTTP- >
<META HTTP-EQUIV="..." CONTENT="...">
<! -EQUIV >
<! NAME >
<META NAME="..." CONTENT="...">
<! N A M E >
</HEAD>
<BODY>
...
</BODY>
</HTML>
HTTP-EQUIV (HTTP-)
EXPIRES .
, . RFC850.
PRAGMA .
NO-CACHE,
. ,
() .
CONTENT-TYPE .
.
360
1. HTML
,
-.
: <>-<>
CACHE-CONTROL .
: (PUBLIC) (PRIVATE)
. (NO-CACHE) , (NO-STORE).
NAME ()
DESCRIPTION . .
, , , . ,
, :
Q URL .
( <TITLE>.. .</TITLE>).
KEYWORDS . , , .
.
<>
361
DOCUMENT-STATE . :
Q STATIC ( , , , , ).
Q DYNAMIC ( , ).
ROBOTS .
:
Q INDEX ( NOINDEX);
Q FOLLOW ,
HTML- ( NOFOLLOW);
U ALL INDEX FOLLOW;
LI NONE NOINDEX NOFOLLOW.
UPDATED .
U R L . U R L , ( ).
< N A M E = " K E Y W O R D S " LANG="ru" C O N T E N T = " m e t a , t a g " >
AUTHOR .
COPYRIGHT .
GENERATOR , HTML-.
, LANG,
.
2.
HTML
HTML
HTML,
.
<!>
, HTML
<!DOCTYPE>
<BASE>
URL-
<BODY>
<>
<DIV>
,
,
<>
<HTML>
HTML
<LINK>
<>
<NEXTID>
<HEAD>
<SPAN>
<STYLE>
<1>
1-
<2>
2-
363
HTML
<>
3-
<4>
4-
<5>
5-
<6>
6-
<TITLE>
<BR>
<CENTER>
<HR>
<NOBR>
<>
<WBR>
<NOBR>
<ADDRESS>
<>
<BASEFONT>
<BIG>
<BLOCKQUOTE>
<1>
<CODE>
<DFM>
<>
<FONT>
<1>
<KBD>
<LISTING>
<PLAINTEXT>
<PRE>
<S>
<SAMP>
364
2. HTML
<SMALL>
<STRIKE>
<STRONG>
<STYLE>
<SUB>
<SUP>
<TT>
<U>
<VAR>
, , ,
<DD>
<DT>
<DIR>
<DL>
<DT>
, <00>
<LI>
<MENU>
<OL>
<LI>
<UL>
<LI>
<CAPTION>
<*
<COLGROUP>
<1_>
<TBODY>
, <TR> <TD>,
<TD>
<TFOOT>
365
HTML
<THEAD>
<TR>
<>
; HREF NAME
< HREF="url">
<> ="">
, ,
<1_>
Java
<AREA>
<BGSOUND>
<EMBED>
<IMG>
<>
<MARQUEE>
<NOSCRIPT>
<OBJECT>
<PARAM>
<SCRIPT>
, ,
,
HTML
<OBJECT>
,
<BUTTON>
HTML
<FIELDSET>
<FORM>
<INPUT>
<LABEL>
~ &
366
2. HTML
<LEGEND>
, , <FIELDSET>
<OPTION>
SELECT
<SELECT>
<TEXTAREA>
<FRAME>
<FRAMESET>
<IFRAME>
<NOFRAMES>
, ,
: ( ). ,
: , .
em, en ex ; , .
Internet Explorer 4 em pt, en .
in, cm, m m , pt, pc: in , cm , mm , pt (72 ) (1 12 ).
, , ,
.
( ),
(
).
367
HTML
font
font
<font-size>, [/<line-height>], <font-family>
<font-size>, <line-height>
, (
, <font-size>, <font-family>). , , .
font-family
font-family
(, Arial)
( , ). . ( serif, sans-serif, cursive, fantasy monospace).
, .
font-size
fontSize
<absoLute>, <relative>, <length>, <percentage>
medium
(
)
:
: xx-small, x-small, small, medium, large,
x-large, xx-large;
: larger, smaller;
(. );
368
2. HTML
:
.
font-style
font-style
normal
fontVariant
normal, small-caps
normal
Normal , ; small-caps , .
font-weight
fontWeight
normal
, .
,
100: 400 , normal, 700 , bold.
color
color
369
.
(, green) RGB. : , "tfFFFFFF", - "80%,20%,0%"; "245,0,20".
background
background
transparent, <>, <11(?1_->, <repeat>,
<>, <>
transparent
( )
, transparent .
, URL. , url:
BODY { b a c k g r o u n d : u r l ( h t t p : / / r a u m u . c o m / i m a g e / p i c t u r e . g i f ) }
, .
. , . :
<repeat> repeat, repeat-x, repeat-y no-repeat; , repeat;
<> , ;
fixed, scroll;
<> ;
(, ), (, ) ( : top, middle, bottom, left, center, right).
,
.
background-attachment
backgroundAttachment
fixed, scroll
scroll
, .
370
2. HTML
background-color
backgroundColor
transparent, <>
transparent
. .
(, green) RGB.
: (, "ttFFFFFF") "80%,20%,0%"; "255".
:
BODY { b a c k g r o u n d - c o l o r : r e d / b l u e }
background-image
backgroundlmage
<URL-aflpec>, none
none
URL- .
,
url.
background-position
backgroundPosition, backgroundPositionX,
backgroundPositionY
<>, <>, top, center, bottom,
left, right
top, left
, ( , ),
( ,
, ), .
background-repeat
backgroundRepeat
repeat, repeat-x, repeat-y, no-repeat
Repeat
371
,
. repeat-x, repeat-y, . .
list-style
HstStyle
< , <>,
<URL-aflpec>
, . . , .
list-style-image
listStylelmage
none, <URL-aflpec>
,
.
list-style-position
stStyle Position
inside, outside
outside
list-style-type
listStyleType
none, circle, disk, square, decimal, lower-alpha,
upper-alpha, lower-roman, upper-roman
disk
372
2. HTML
, .
, .
: letter-spacing
letterSpacing
normal, <>
normal
. . .
: line-height
lineHeight
.
, (, 1,2). ,
. 100%.
: text-align
textAlign
left, right, center, justify
, .
, , <DIV ALIGN= .. .>.
: text-decoration
textDecoration, textDecorationLineThrough,
textDecorationUnderline, textDecorationOverline
373
none, overLine, underline, line-through
. , .
, , .
: text-indent
textlndent
<>, <>
zero
.
.
: text-transform
textTransform
none
capitalize ;
uppercase ;
lowercase ;
, .
: vertical-align
verticalAlign
baseline, sub, super, top, text-top, middle,
bottom, text-bottom, <>
baseline
baseline ;
374
2. HTML
middle
;
super ;
sub ;
text-top , ;
text-bottom , ;
top
;
bottom
.
. , . .
borderTopColor, borderRightCoLor,
borderLeftCobr, borderBottomColor,
borderCoLor
<>
< >
. URL- , , .
borderTopStyle, borderRightStyle,
borderLeftStyle, borderBottomStyle,
borderStyle
none, solid, double, groove, ridge, inset,
outset
none
375
. , (. ), , :
<_> medium, thin thick ;
<_> solid.
color ,
, . , , .
borderTopWidth, borderRightWidth,
borderLeftWidth, borderBottomWidth,
borderWidth
medium
'
.
. border-width ,
m a r g i n .
clear
clear
, , . .
376
2. HTML
clip
clip
rect(<top><right><bottom><Left>), auto
auto
, . , , , .
display
display
"",
, .
float
style Float
none
DIV, SPAN
.
height
auto, <>
auto
DIV, SPAN
, .
, (, % . .).
posHeight.
left
377
auto
,
. , (, % . .).
posLeft.
. margin
. , , . .
overflow
overflow
auto
, ,
:
visible ,
; ;
hidden -
;
auto , -;
scroll .
378
2. HTML
zero
. padding
.
, ,
.
position
position
relative
,
:
absolute
;
static (relative), ,
left top;
relative
(
).
top
auto
,
.
, (, % . .).
posTop.
visibility
visibility
inherit
379
.
(hidden) , (visible), .
, :
visible ;
hidden ;
inherit ,
.
width
auto
DIV, SPAN
, .
, (, % . .).
posWidth.
z-index
. zlndex
<>
HTML
z-index ,
. z-
z-. , . ,
, .
page-break-after
pageBreakAfter
<auto>, <always>, <left>, <right>
380
2. HTML
<auto>
'
, , , .
page-break-before
pageBreakBefore
<auto>
, , , .
filter. : . : ()
. , . 23 . :
f i l t e r : _(!, 2, . .)
14 2 .
Visual filters
.style.<_>(! . .)
< >(1, ? . .)
.
.
alpha
blur
chroma
dropShadow
(transparent)
,
, ,
381
fliph
flipv
glow
grey
invert
Light
mask
(transparent) ,
redirect
DAImage-, ,
Microsoft DirectAnimation
shadow
wave
-,
revealTrans
, style. revealtrans(duration =
<>, transition = < >)
revealtrans (duration = <>,
transition = < >)
, 23 (. . ).
<> , ( ).
< > , .
Box In ( )
Box Out ( )
Circle In ( )
Circle Out ( )
Wipe Up ( )
Wipe Down ( )
Wipe Right ( )
Wipe Left ( )
Vertical Blinds ( )
()
382
2. HTML
Horisontal Blinds ( )
Checkerboard Across ( )
10
Checkerboard Down ( )
11
Random Dissolve ( )
12
Split Vertical In ( )
13
14
Split Horisontal In ( )
15
16
17
Strips Left Up ( -)
18
19
Strips Right Up ( -)
20
21
22
blendTrans
.style.blendtrans
blendTrans(duration= <>),
(duration = <>)
. <> , ( ).
cursor
cursor
auto, crosshair, default, hand, move, e-resize,
ne-resize, nw-resize, n-resize, se-resize,
sw-resize, s-resize, w-resize, text, wait, help
auto
383
HTML
onabort
onafterupdate
onBeforeunload
onbeforeupdate
onblur
onbounce
<MARQUEE>, BEHAVIOR
ALTERNATE,
onchange
onclick
ondataavauable
ondatasetchanged
ondatasetcomplete
ondbLclick
ondragstart
onerror
onerrorupdate
onbeforeupdate,
onafterupdate
onfilterchange
onfilterevent
onfinish
<MARQUEE>
onfocus
onhelp
F1 Help
onkeydown
onkeypress
onkeyup
onload
onmousedown
onmousemove
onmouseout
onmouseover
onmouseup
onreadystatechange
readystate
onreset
384
onresize
onrowenter
onrowexit
onscroll
onselect
2. HTML
onselectstart
onstart
MARQUEE
onsubmit
onUnload
SUBMIT ()
1-9
-, 335
ActionScript, 271,275
Active Server Pages, 277
ActiveX, 248, 267, 273, 278, 348
Adobe Photoshop, 322
AIFF, 349
ASCII-, 36, 49, 72, 252, 315
Get-, 279
GMT, 85
HTML, 297
, 116
,
HTML-, 297
, 263
, 349
, 154,156, 224
, 350
, 196
, 242
, 115
HTML-, 114,297
, 299
HTML-, 114, 297, 298, 302
, 298
, 298
HyperText Markup Language, 297
J
JScript, 118
FileSystemObject, 267, 277, 278, 287
Flash-, 272-273
-, 347
, 273
Flash-, 272-273,348
Flash-, 276
M
Macromedia Dreamweaver, 19, 300
Macromedia Flash, 188, 271, 274, 347
Microsoft FrontPage, 19, 300, 301, 303
Microsoft Internet Explorer, 16
386
N
Netscape, 16
Q
QuickTime, 349
R
RealAudio, 349
RealPlayer, 349
RGB-, 307
script, 116
Simple Tabular Data, 248
STD, 248, 249, 250, 252, 255, 259
swf-, 276
VisualBasicScript, 116
w
WAV, 349
Windows Scripting Host, 16, 277
, 323
, 188
, 173,365
()
, 265
, 253
, 255
, 256
, 313
, 277
Windows, 14,15, 18, , 248, 291,
294,299,318
, 374
JavaScript, 22
-, 16, 299
, 169
-, 232
-, 114
, 316
, 211
, 167
, 267, 271
, 168
, 296
, 32
, 46
JavaScript, 46
, 162
, 46
, 81
,83
, 84
, 205
, 113,320
, 221
, 220
, 321
, 229
, 252, 255
387
, , 89
, 85
, 33
, 114
, 118
, 19
, 37
, 223
HTML
, 383
, 67
, 185
, 65, 91
, 290
, 248
, 290
, 317
, 317
, 321
, 158
, 180
, 192
, 196
, 317
, 194, 346
, 191
, 189
, 178
, 159
, 192
, 317
, 14
, 308
, 310
, 33
JavaScript, 18,117
, 13
, 43
, 42
, 28
, 29
, 335
, 116
, 248
, 30,31, 38,40,44, 48, 58,
108,109, 258
new, 67,96
this, 97
var, 52,53
, 354
, 359
, 302
, 25,34
, 37
, 26
, 304
, 37
, 66
, 68
, 69
, 67,68
, 73
, 67
,68
, 67, 68
, 234, 236
, 237
, 237
, 237
388
{)
boldQ, 63
BuildPathQ, 285
clearlnterval(), 162
clearTimeout(), 162
Close(), 285, 287
close(), 142
confirm(), 23, 136
CopyFolderQ, 283
CreateTextFile(), 284, 288
cuptureEventQ, 138
DeletcFolder(), 283
document.clear(), 155
document.write(), 155
fso.DriveExists(), 279
fso.GetDriveQ, 279
GetBaseName(), 285
getElementById(), 130
GetExtensionName(), 285
MoveFolder(), 283
open(), 142
OpenAsTextStream, 287
OpenTextFile, 284, 287
prompt, 24
Read(), 288
ReadAllQ, 288
ReadLine(), 288
RegDelete(), 295, 296
RegRead(), 295
RegWriteQ, 295
Run(), 292
ScipLine(), 288
setlnterval(), 161
setTimeout(), 162
showModalDialogQ, 142
Skip(), 288
SpecialFoldersQ, 290
String, 66
, 57, 58
, 63
window.createPopupQ, 152
window.open(), 142
writeQ, 63, 101, 104, 155,289
WriteBlankLines(), 289
WriteLine(), 289
()
writelnQ, 155
WScript.Echo(), 278
, 22
, 183
, 181
, 148
, 120, 123
, 22, 136
, 121, 181
onclick, 139
onfocus, 140
, 28
, 56,112
Array, 56, 66, 67
, 70, 101
, 69
Boolean, 91
Date, 56, 85
, 86
, 85
document, 172
, 173
, 173
, 172
, 174
event, 132, 135, 177
, 177
Function, 55, 91
, 93
, 92
, 91
history, 175
, 176
location, 175
, 175
, 175
Math, 56, 79
, 79
, 79
()
navigator, 176
, 177
, 176
Number, 74, 77
, 77
, 77
Object, 95
popup, 152
, 152
, 152
screen, 178
, 178
String, 56, 57, 58, 64
, 58
TextRange, 178,242
, 178
, 178
window, 169
, 171
, 169
, 171
Wscript.Shell, 290, 292
, 55, 56,124
, 98
, 124
, 126
, 126
, 96
, 124
, 99
, 97
, 99
, 99
, 124, 125
, 151
, 22, 142
, 142
, 141,142
, 141
, 172
, 32, 34, 36
, 32
&, 103
389
()
+=, 102
, 103
, 103
>, 103
, 103
1,103
-,103
break, 40, 43,44
continue, 44
default, 40
delete, 104
do-while, 45
GOTO, 110
in, 104
instanceof, 105
return, 50
switch, 41
tipeof, 106
, 33, 34,47
, 33
, 33
, 32
, 105
, 37, 47
, 32
, 104
, 33, 37
, 103
, 46,106,107
, 42
, 30, 31, 32, 35, 52, 56, 57, 67,
95, 202
, 34
, 32, 33
, 35, 252
, 105
, 38, 43, 47
if, 38,42
switch, 40
, 42, 247
for, 42,102
while, 44
, 42
, 42
390
, 19
, 323
, 221
,
, 283
, 290
, 282
, 167, 168, 267, 268, 269
, 168
, 271
, 25
JavaScript, 272
, 351
, 29, 30
, 32
, 30
, 31, 52
, 30
, 31
,.31
, 31, 52
, 31
, 32
, 32
, 30
, 31
, 31
, 31
, 203
, 198
, 196
, 200
, 198
, 379
, 182
, 60
, 64
, 241, 258
, 241
, 24, 241,350
, 253
, 312
, 27
, 76
, 27
, 38
-, 111
, 112
, 302
, 24, 26, 39
, 279
, 248
, 317
, 234
, 109
, 20
, 292
reg-, 293
, 294
, 293
DWORD, 294
rcgedit.exe, 293
, 292
, 294
, 295
, 295
, 259
, 80
, 217
, 211
, 220
, , 218
,212
,212
, 214
button, 133
innerHTML, 157
391
()
innerText, 156
length, 58,176
outerHTML, 157
outerText, 156
prototype, 57
, 114
, 314
, 262
, 75
,75
, 75
, 42, 72
, 47, 50, 106
, 39, 44, 97
,187
, 28,314
, 121, 131
onchange, 121
onclick, 121,133
onmouseover, 121
, 137
, 138
, 131
, 22
, 57
, 310
, 371
, 310
, 364
, 258, 320
, 320
, 184
, 323
, 245
, 291
, 320
, 333
, 305
, 156, 334
, 335
, 305
()
, 304
, 305
, 335
, 305
, 305
, 337, 339
, 305
, 363
, 305
, 32,116,117, 302
, 117
, 119
, 88
, 66
, 266
, 244,325
, 331
HTML-, 263
, 251
, 329
, 247
/ , 246
,244
, 326
, 246
, 327
, 329
, 101
, 364
, 248
, 156,185, 347,366
, 91
, 114, 297
<!>,302
<AHREF>, 148
<BODY>, 120, 298
<BR>, 114, 297
<BUTTON>, 354
<CAPTION>, 326
<CENTER>, 302
<DIV>, 135,138, 302
392
()
<EMBED>,273, 350
<FONT>, 306
<FORM>, 126,182,229
<FRAME>, 114, 144,356
<FRAMESET>, 144,148, 169
<HEAD>, 120
<HR>,312
<HTML>, 297
<IFRAME>, 150, 209
<IMG>, 114,180,317
<INPUT>, 350
<MAP>, 321
<MARQUEE>, 313
<META>, 301,359
<OBJECT>, 116, 248, 249,347
<OPTION>, 234
<P>, 185,303
<PRE>,310
<SCRIPT>, 18, 118,278,302
<SELECT>, 159, 234
<STYLE>, 116, 333
<TABLE>, 101, 244, 250, 326
<TEXTAREA>, 195, 243
<TITLE>, 298
<HEAD>, 298
, 363
, 114,297
EVENT, 123
FOR, 123
ID, 122,126
. LANGUAGE, 118
LOWSRC, 158
SRC, 118
STYLE, 116
,155
, 362
, 297
, 119
, 114, 297
, 297
, 297
, 362
, 114
, 308
, 302
, 182
, 335
, 310
, 372
, 115, 303
, 309
, 178
, 207
, 243
, 14, 18, 248, 298
, 25
Null, 25
, 26
, 25, 26
, 25
, 25
, 25
, 25
, 66
, 161
cookie.txt, 163
cscript.exe, 277
reg.dat, 292
system.dat, 292
user.dat, 292
wscript.exe, 277
, 285
, 288
, ,
, 286
, 287
, 289
, 284
, 355, 356
, 287
, 277
, 278
393
, 43
, 305
, 189, 252
alpha, 189
basic! mage, 194
blur, 340
fliph, 340,341
revealtrans, 191
wave, 341
GIF, 188
JPEG, 188
PNG, 188
SWF, 188
, 58, 63
, 325
, 140,144, 355
, 149
, 150
, 151.
,'208
, 149
, 366
, 146
, 48
alert(), 28
aSumQ, 70
buildMenuQ, 237
()
changc(), 147
creatcFileQ, 285
createFoldcrQ, 282, 285
curvcQ, 217
driveinfoQ, 279
driveTotallnfoO, 280, 281
escapeQ, 164
eval(), 49, 82, 83, 84,160,200
factorialQ, 54
FileToArrayQ, 290
getCookieValQ, 165
getitQ, 273
getproperties (), 158
isNaNQ, 27
loadQ, 148
ItrimQ, 66
parscFIoatQ, 27, 76, 266
parselntQ, 27, 76
pop(), 153
promptQ, 351
readCookie(), 165
rtrimQ, 66
statisticQ, 74
tol6(),75, 76
to2(), 76
transformQ, 191
trimQ, 66
typcOt'Q, 50
unescapeQ, 49, 165
writeCookieQ, 166
wrtext(), 195
, 64
, 48
, 51,55,92, 94
, 54
escapc(), 49
, 64
, 50
, 50, 55
, 50
, 243
, 48, 50
, 54
, 80
394
()
, 50
, 65
-, 97
()
, 309, 363
, 367
, 305
, 183
, 368
, 309
, 309
, 42
, 42
, 230
, 233
, 264
, 195
, 180, 188, 216, 333
, 225
, 27, 74
, 74
, , , 306
C++, 111
HTML,
Java, 113
Object Pascal, 111
, 113
, 111
, 324
, 290
, 290, 291
JavaScript
2-
.
.
.
. , .
. , .
.
05784 07.09.01.
. 194044, -, . . , . 29.
005-93, 2; 953005 .
20.01.05. 70X100/16. . . . 32,25. 3000 . 9227.
. . .
, .
197110, -, ., 15.
(/,
1 997
-
. ,
. ,
.
,
.
:
;
(, );
( ).
?
) :
www.piter.com;
postbook@piter.com . (81 2) 1 03-73-74;
500
.
, . , , .
- , :
1 5% , ;
- 3%;
;
- .
w w. p i .
www.piter.com
:
, ,
CD
,
!
-
:
: (812) 103-73-74;
: postbook@piter.com;
: www.piter.com;
: 197198, -, / 619,
.
^
. (
). -
.
(
-).
.
:
, , , , , e-mail;
, , , ,
, , , ;
, , ,
.
WWW.PITEfl.COM
WWW.PITER.COM
, ,
,
WWW.P1TER.COM
!
.
, , . , . 70 ( ),
. , . , . 88,
./ (3472) 50-39-00.
E-mail: asiaufa@ufanet.ru
, ,
./ (3912) 27-39-71.
E-mail: book-world@public.krasnet.ru
, ,
./ (4232) 23-82-12.
E-mail: bookbase@mail.primorye.ru
, ,
. (3466) 23-27-14, 23-59-50.
E-mail: book@nvartovsk.wsnet.ru
, ,
. (4212) 30-54-47, 22-73-30.
E-mail: sale_book@bookmirs.khv.ru
, -,
. (3832) 36-10-26, 36-10-27.
E-mail: office@top-kniga.ru
http://www.top-kniga.ru
, ,
. (4212) 32-85-51, 32-82-50.
E-mail: postmaster@worldbooks.kht.ru
, ,
./ (3452) 21-34-82.
E-mail: drug@tyumen.ru
, ,
. (8182) 65-41-34, 65-41-34.
E-mail: book@atnet.ru
, ,
. (3452) 27-36-06, 27-36-11.
E-mail: foliant@tyumen.ru
, ,
./ (0112) 21-56-28,21-62-07.
E-mail: nshibkova@vester.ru
http://www.vester.ru
, , . , . 61,
./ (3512) 52-49-23.
E-mail:evri ka@chel.surnet.ru
, , . , 424,
./ (87934) 6-93-09.
E-mail: rossy@kmw.ru
, ,
. (3952) 59-13-70, 51-30-70.
E-mail: prodalit@irk.ru
http://www.prodalit.irk.ru
, -,
./ (3952) 33-42-47.
E-mail: antey@irk.ru
, ,
. (8432) 72-34-55, 72-27-82.
E-mail: tais@bancorp.ru
, 14,
. , . 23,
./ (3432) 53-24-90.
E-mail: gvardia@mail.ur.ru
, -,
. , . 5,
./ (3432) 42-56-00.
E-mail: valeo@etel.ru
www.drweb.ru
()
. ;
JavaScript;
-.
JavaScript
2-
JavaScript.
.
-, ,
Windows Scripting Host. JavaScript HTML
, , -
.
- !
ISBN 5-469-00804-5
:
197198, -, / 619
.: (812)103-73-74, postbook@piter.com
61093, -93, / 9130
.: (057)712-27-05, piter@kharkov.piter.com
9"785469"008040'
www.piter.com - - -