You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 1-js/1-getting-started/4-devtools/article.md
+4-6Lines changed: 4 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,7 +24,7 @@ Open the page [bug.html](bug.html).
24
24
25
25
There's an error in the JavaScript code on it. An ordinary visitor won't see it, we need t open developer tools for that.
26
26
27
-
Press the keys[key Ctrl+Shift+J] or, if you're on Mac, then [key Cmd+Shift+J].
27
+
Press the key[key F12] or, if you're on Mac, then [key Cmd+Opt+J].
28
28
29
29
The developer tools will open on the Console tab by default.
30
30
@@ -51,7 +51,7 @@ It is done on the "Advanced" pane of the preferences:
51
51
52
52
<imgsrc="safari.png">
53
53
54
-
Now [key Cmd+Alt+C] can toggle on the console. Also the new top menu item has appeared with many useful options.
54
+
Now [key Cmd+Opt+C] can toggle the console. Also the new top menu item has appeared with many useful options.
55
55
56
56
## Other browsers
57
57
@@ -62,10 +62,8 @@ The look & feel of them is quite similar, once we know how to use one of them (c
62
62
## Summary
63
63
64
64
<ul>
65
-
<li>
66
-
Developer tools allow us to see errors (crucial now), run commands, examine variables and much more.</li>
67
-
<li>
68
-
They can be opened with [key F12] for most browsers, with the exception of Chrome ([key Ctrl+Shift+J] / [key Cmd+Shift+J]) and Safari (need to enable, then [key Cmd+Alt+C]).
65
+
<li>Developer tools allow us to see errors (crucial now), run commands, examine variables and much more.</li>
66
+
<li>They can be opened with [key F12] for most browsers under Windows. Chrome for Mac needs [key Cmd+Opt+J], Safari: [key Cmd+Opt+C] (need to enable first).
Copy file name to clipboardExpand all lines: 1-js/2-first-steps/1-hello-world/article.md
+30-47Lines changed: 30 additions & 47 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,89 +6,72 @@ In this chapter we'll create a simple script and see it working.
6
6
## The "script" tag
7
7
8
8
[smart header="What if I want to move faster?"]
9
-
In the case if the impatient reader developed with JavaScript already or has a lot of experience in another language, he can skip detailed explanatins and jump to [](/javascript-specials). There he can find a condensed essense of important features.
9
+
In the case if an impatient reader has developed with JavaScript already or has a lot of experience in another language, he can skip detailed explanatins and jump to [](/javascript-specials). There he can find an essense of important features.
10
10
11
11
If you have enough time and want to learn things in details then read on :)
12
12
[/smart]
13
13
14
-
Программы на языке JavaScript можно вставить в любое место HTML при помощи тега `SCRIPT`. Например:
14
+
JavaScript programs can be inserted in any place of HTML with the help of the `<script>` tag.
<dd>Тег `script` содержит исполняемый код. Предыдущие стандарты HTML требовали обязательного указания атрибута `type`, но сейчас он уже не нужен. Достаточно просто `<script>`.
40
+
You can run the example clicking on a "Play" button in it's right-top corner.
47
41
48
-
Браузер, когда видит `<script>`:
49
-
<ol>
50
-
<li>Начинает отображать страницу, показывает часть документа до `script`</li>
51
-
<li>Встретив тег `script`, переключается в JavaScript-режим и не показывает, а исполняет его содержимое.</li>
52
-
<li>Закончив выполнение, возвращается обратно в HTML-режим и *только тогда* отображает оставшуюся часть документа.</li>
53
-
</ol>
42
+
The `<script>` tag contains JavaScript code which is automatically executed when the browser meets the tag.
54
43
55
-
Попробуйте этот пример в действии, и вы сами всё увидите.
56
-
</dd>
57
-
<dt>`alert(сообщение)`</dt>
58
-
<dd>Отображает окно с сообщением и ждёт, пока посетитель не нажмёт "Ок".</dd>
59
-
</dl>
60
-
61
-
[smart header="Кодировка и тег `META`"]
62
-
При попытке сделать такой же файл у себя на диске и запустить, вы можете столкнуться с проблемой -- выводятся "кракозяблы", "квадратики" и "вопросики" вместо русского текста.
44
+
Please note the sequence:
63
45
64
-
Чтобы всё было хорошо, нужно:
65
46
<ol>
66
-
<li>Убедиться, что в `HEAD` есть строка `<meta charset="utf-8">`. Если вы будете открывать файл с диска, то именно он укажет браузеру кодировку.</li>
67
-
<li>Убедиться, что редактор сохранил файл именно в кодировке UTF-8, а не, скажем, в `windows-1251`.</li>
47
+
<li>Browser starts to parse/show the document, makes it up to the `<script>`.</li>
48
+
<li>When the browser meets `<script>`, it switches to the JavaScript execution mode. In this mode it executes the script. In this case `alert` command is used which shows a message.</li>
49
+
<li>When the script is finished, it gets back to the HTML-mode, and *only then* it shows the rest of the document.</li>
68
50
</ol>
69
51
70
-
Указание кодировки -- часть обычного HTML, я упоминаю об этом "на всякий случай", чтобы не было сюрпризов при запуске примеров локально.
71
-
[/smart]
52
+
So, a visitor won't see the content after the script until the script finishes to execute.
72
53
54
+
People say about that: "a `<script>` tag blocks rendering".
73
55
74
-
## Современная разметка для SCRIPT
75
56
76
-
В старых скриптах оформление тега `SCRIPT` было немного сложнее. В устаревших руководствах можно встретить следующие элементы:
In the past, `<script>` had a few necessary attributes.
60
+
61
+
We can find the following in the old code:
80
62
81
-
<dd>В отличие от HTML5, стандарт HTML 4 требовал обязательного указания этого атрибута. Выглядел он так: `type="text/javascript"`. Если указать другое значение `type`, то скрипт выполнен не будет.
В современной разработке атрибут `type` не обязателен.
66
+
<dd>The old standard HTML4 required a script to have the type. Usually it was `type="text/javascript"`. The modern HTML standard assumes this `type` by default, no attribute is required.
<dd>Этот атрибут предназначен для указания языка, на котором написан скрипт. По умолчанию, язык -- JavaScript, так что и этот атрибут ставить не обязательно.</dd>
88
-
<dt>Комментарии до и после скриптов</dt>
89
-
<dd>В совсем старых руководствах и книгах иногда рекомендуют использовать HTML-комментарии внутри `SCRIPT`, чтобы спрятать Javascript от браузеров, которые не поддерживают его.
<dd>This attribute was meant to show the language of the script. Certain outdated browsers supported other languages at that time. As of now, this attribute makes no sense, the language is JavaScript by default. No need to use it.</dd>
71
+
<dt>Comments before and after scripts.</dt>
72
+
<dd>In the most pre-historic books and guides, `<script>` may have comments inside.
90
73
91
-
Выглядит это примерно так:
74
+
Like this:
92
75
93
76
```html
94
77
<!--+ no-beautify -->
@@ -97,9 +80,9 @@ If you have enough time and want to learn things in details then read on :)
97
80
//--></script>
98
81
```
99
82
100
-
Браузер, для которого предназначались такие трюки, очень старый Netscape, давно умер. Поэтому в этих комментариях нет нужды.
83
+
These comments were supposed to hide the code from an old browser that did't understand a `<script>` tag. But all browsers from the past 15 years know about `<script>`, so that's a really ancient theme. Giving this for the sake of completeness only. So if you see such code somewhere you know the guide is really ancient and not worth looking into.
101
84
</dd>
102
85
</dl>
103
86
104
-
Итак, для вставки скрипта мы просто пишем `<script>`, без дополнительных атрибутов и комментариев.
87
+
In summary, we just use `<script>` to add some code to the page, without additional attributes and comments.
Возьмите решение предыдущей задачи [](/task/hello-alert) и вынесите скрипт во внешний файл `alert.js`, который расположите в той же директории.
5
+
Take the solution of the previous task [](/task/hello-alert). Modify it by extracting the script content into an external file `alert.js`, residing in the same folder.
6
6
7
-
Откройте страницу и проверьте, что вывод сообщения всё ещё работает.
0 commit comments