��� ����: ����� ����� / ����� 3 / �� 3
 


������ �� ��� �- JavaScript
 


���� ������ ��:
1: JavaScript �����
2: ���� ����� �������
3: ������ ����� � ���?
4: ������ ������� � ���?
5: ���� JavaScript
6: ����� ��� �� ������
7: ����� ��� �������
8: ����� ��� �������
9: ������ ������ ������
10: ������� ���������
11: ���� 3 - ����
|
|
|
|
|
|
|
|
|
|
|
|

����� 3

�� 3: ������ ����� � ���?

�� ��� ���� ��, ����� �� ��� ���� ���� ������� (��� ����� ����� ����, ���� ����� ����� ����� �� ���� � ���� ��). ��� ���� ������ ����� ���: ��� ����� onClick ��� ���� �������� ����:

function ringBell()
{
  var timer1 = setTimeout("window.document.the_form.the_text.value='3 seconds!';",3000);
  var timer2 = setTimeout("window.document.the_form.the_text.value='6 seconds!';",6000);
  var timer3 = setTimeout("window.document.the_form.the_text.value='9 seconds!';",9000);
}

�����, " ���� '3 �����' ���� ����� ������, '6 �����' �� ����� ������, �'9 �����' ��� ����� ������. ������, ����?

��� ����, ������ ���� �� �����:

function doDumbTimer()
{
  var timer1 = setTimeout("window.document.the_form.the_text.value='3 seconds!';",3000);
  var timer2 = setTimeout("window.document.the_form.the_text.value='6 seconds!';",3000);
  var timer3 = setTimeout("window.document.the_form.the_text.value='9 seconds!';",3000);
}

���� �� ���� ���� ����� ��� ����� ����?

��� ��, �� �� ��� ���� ���� �����, ��� ���� ����� ������ ������ ������ ����� ������ ����� ����� ����� ����� ��. ���� ����� �����, �� ��� ��- setTimeout ������ �������, (������, ��� �����, "���� '3 �����' ���� ����� ������, '6 �����' ���� ����� ������, �-'9 �����' ���� ����� ������"). ��, ���� ����� ���� �����, �� ����� ������ ����� ��� ���, ���� ����� ���� �� ������ ����� �������� ������ � ����� �� �� �����.

���� ����� ���, ()setTimeout ��� �� ��� ������. ��� ����,�� ���� ����� ��� ����: ��� ��� ���� ����� ���� ��� ��� ���� ���� �� ��� �����, ������ ��� ����? ������:

�� ���� ���� ����� ����� �� ���� ���� ���, ��� ����� �� clearTimeouts ��� ���. ���� �� ��� ����� ����� ���� ���� ������ ��������. �� ����� ���� ����� ����, ��� �� ����� �����. ��� ������� ����, ���� ��� ���� ����� ������ ���� ������� ����� ���� ������ HTML ������, ���� ����� ����� ��� ����: "��� �� �� ���, ���, ��� ��� ���, ���...��� ����".

��� ��� ���� �� ��?

����, ������ ���� ���. ��� �� ���� ������� , ��� �� �����, ��� ���� �� ���� ����� �� ��� �����, ���:

function theTimer()
{
  var timer1 = setTimeout("changeTextBoxTo(2);",2000);
  var timer2 = setTimeout("changeTextBoxTo(4);",4000);
  var timer3 = setTimeout("changeTextBoxTo(6);",6000);
  var timer4 = setTimeout("changeTextBoxTo(8);",8000);
  var timer5 = setTimeout("changeTextBoxTo(10);",10000);
  .
  .
  .
}

��� ����, �� ��, ����� ���� ��: �� ��� ���� ����� ���� ������ ��������, ������� ������ ���, ���� ����� �� ��' ������� �� ����� ���. ��� ����� �����, ��� carpal tunnel syndrome �����, ���� ��� �� ������ �� ����� �� ��' ����� ������� �� JavaScript, ��� ���� �� ���� ������.

�� ������ ���� �� �����, ����� ���� ����� �� ����:

function theTimer()
{
  the_time = 0;
  hellIsHot = true;

  while (hellIsHot == true)
  {
    the_time += 2;
    var timer = setTimeout("changeTextBoxTo(the_time);", the_time*1000);
  }
}

��� ��� ��� ��, �� ��� ����� ��� ��� ����. �� �� ���� ����� �� ������. ������� ������ ���� ����. ��� ����� �� ��' ����� ������ �-"while":

���� 1

while (hellIsHot == true)

��, ����� �� �������.

the_time += 2;

��� ������ the_time ���: 2.

var time = setTimeout("changeTextBoxTo(2);", 2000);

��, ��� ����� ������, ���� ����� ����� �- "2". ��� �� ���� �����.

���� 2

while (hellIsHot == true)

��, ����� �� �������.

the_time += 2;

��� ������ the_time ���: 4.

var time = setTimeout("changeTextBoxTo(4);", 4000);

��, ���� ����� ������, ���� ����� ����� �- "4". ���, �� ����.

���� 3

while (hellIsHot == true)

��, ������� �� ���� �� ����.

the_time += 2;

��� ������ the_time ���: 6.

var time = setTimeout("changeTextBoxTo(6);", 6000);

��, �� ����� ������, ���� ����� ����� �-"6". ���.

���� 4

while (hellIsHot == true)

���, ���, ������� ��!

��� ���� ��� ���� ��� ���� ...

���� �� ������. ���� ����� ��� �� ���� �� ������ ������. ���� �����, ��� ��. ����� ���, ���� ���� ����� ��������, ������ ���� setTimeout �� ��������� ����. ������ ��� ��� �����. ����� ������� ���, ���� ������ ���� ������, ��� �� ���� ����� ��� ��� ��� �������. ��� ������ ����, ���� ��� "����� �� ������" ����� setTimeout ���. ����� ����� ���, �� ��� � � setTimeout ����, ������ ���� ����� �� ��� ����� �����, ���� ��� ���� ����� ���. ����� �� ��� ������ ������ ��� �����. ���� �� ����, ������ �����, �� ������ �����, �� ���� ������ ����� �� ����� �� ���� �� JavaScript �����.

�� ��� ����.

����� ����, �� ��� ����� ���� ��� ������ �����.

���� ������ ���

��� ��� «--

 
       
       
   
 
 

���� ����
����� �����
����� �����
����� ������
����� ���
��� ����