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/02-first-steps/01-hello-world/2-hello-alert-ext/task.md
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -2,8 +2,8 @@ importance: 5
2
2
3
3
---
4
4
5
-
# Show an alert with an external script
5
+
# Xəbərdarlığı kənar skriptdən göstər
6
6
7
-
Take the solution of the previous task <info:task/hello-alert>. Modify it by extracting the script content into an external file `alert.js`, residing in the same folder.
7
+
Əvvəlki <info:task/hello-alert> tapşırığında olan skripti eyni direktoriyada olan `alert.js` faylına ixrac edin.
This part of the tutorial is about core JavaScript, the language itself.
3
+
Dərsliyin bu hissəsində JavaScript dilinin özündən danışılır.
4
4
5
-
But we need a working environment to run our scripts and, since this book is online, the browser is a good choice. We'll keep the amount of browser-specific commands (like `alert`) to a minimum so that you don't spend time on them if you plan to concentrate on another environment (like Node.js). We'll focus on JavaScript in the browser in the [next part](/ui)of the tutorial.
5
+
Lakin, skriptləri icra etmək üçün bizə işlək mühit lazımdır. Bu kitab onlayn olduğundan bu skriptləri icra etmək üçün brauzer daha yaxşı seçimdir. Sizin fərqli mühitə (Node.js kimi) keçmək istədikdə brauzerə xas əmrlərin (`alert` kimi) üzərində çox vaxt xərcləməməniz üçün biz bu əmrləri çox az işlədəcəyik. Dərsliyin [sonrakı bölməsində](/ui)brauzerdə JavaScript haqqında danışacağıq.
6
6
7
-
So first, let's see how we attach a script to a webpage. For server-side environments (like Node.js), you can execute the script with a command like `"node my.js"`.
7
+
Gəlin ilk olaraq skripti səhifəyə qoşaq. Server mühitlərində (Node.js kimi) skripti `"node my.js"` formalı əmr ilə icra edə bilərsiniz.
8
8
9
9
10
-
## The "script" tag
10
+
## "script" təqi
11
11
12
-
JavaScript programs can be inserted into any part of an HTML document with the help of the `<script>` tag.
12
+
`<script>` təqindən istifadə edərək JavaScript proqramlarını HTML sənədinin istənilən yerinə əlavə etmək olar.
13
13
14
-
For instance:
14
+
Məsələn:
15
15
16
16
```html run height=100
17
17
<!DOCTYPE HTML>
18
18
<html>
19
19
20
20
<body>
21
21
22
-
<p>Before the script...</p>
22
+
<p>Skriptdən öncə...</p>
23
23
24
24
*!*
25
25
<script>
26
-
alert( 'Hello, world!' );
26
+
alert( 'Salam, dünya!' );
27
27
</script>
28
28
*/!*
29
29
30
-
<p>...After the script.</p>
30
+
<p>...Skriptdən sonra.</p>
31
31
32
32
</body>
33
33
34
34
</html>
35
35
```
36
36
37
37
```online
38
-
You can run the example by clicking the "Play" button in the right-top corner of the box above.
38
+
Yuxarıdakı qutunun yuxarı sağ küncündə yerləşən "Play" düyməsini tıklayaraq bu nümunəni icra edə bilərsiniz.
39
39
```
40
40
41
-
The`<script>`tag contains JavaScript code which is automatically executed when the browser processes the tag.
41
+
Brauzer`<script>`təqini emal edən kimi təqdə olan JavaScript kodu avtomatik icra olunacaq.
42
42
43
43
44
-
## Modern markup
44
+
## Modern markap
45
45
46
-
The `<script>`tag has a few attributes that are rarely used nowadays but can still be found in old code:
46
+
`<script>`təqinin indiki zamanda çox az işlədilən, amma köhnə kodlarda tapa biləcəyiniz bir neçə atributları var.
47
47
48
-
The `type`attribute: <code><script <u>type</u>=...></code>
49
-
: The old HTML standard, HTML4, required a script to have a `type`. Usually it was `type="text/javascript"`. It's not required anymore. Also, the modern HTML standard totally changed the meaning of this attribute. Now, it can be used for JavaScript modules. But that's an advanced topic; we'll talk about modules in another part of the tutorial.
: Köhnə HTML standartı olan HTML4-də skript təqinin `type` atributunun olması vacib idi. Bu atributun dəyəri adətən `type="text/javascript"` idi. Bu artıq lazım deyil. Əlavə olaraq, modern HTML standartında bu atributun mənası tam dəyişmişdir. İndi, bu atribut JavaScript modulları üçün işlədilə bilər. Biz modullar haqqında bu dərsliyin digər bölməsində danışacağıq.
50
50
51
-
The `language`attribute: <code><script <u>language</u>=...></code>
52
-
: This attribute was meant to show the language of the script. This attribute no longer makes sense because JavaScript is the default language. There is no need to use it.
: Bu atributda skriptin dili göstərilirdi. JavaScript-in əsas dil olduğundan bu atributun artıq mənası qalmayıb. Bu atributdan istifadə etmək lazım deyil.
53
53
54
-
Comments before and after scripts.
55
-
: In really ancient books and guides, you may find comments inside `<script>`tags, like this:
54
+
Skriptlərdən öncə və sonra kommentlər.
55
+
: Çox köhnə kitab və ya məqalələrdə `<script>`təqlərində aşağıdakı şəkildə olan kommentlər tapa bilərdiniz:
56
56
57
57
```html no-beautify
58
58
<script type="text/javascript"><!--
59
59
...
60
60
//--></script>
61
61
```
62
62
63
-
This trick isn't used in modern JavaScript. These comments hide JavaScript code from old browsers that didn't know how to process the `<script>` tag. Since browsers released in the last 15 years don't have this issue, this kind of comment can help you identify really old code.
63
+
Modern JavaScript-də bu hiylədən istifadə edilmir. Bu kommentlər `<script>` təqini emal edə bilməyən köhnə brauzerlərdə JavaScript kodunu gizlətmək üçün lazım idi. Sonuncu 15 ildə dərc olunmuş brauzerlərdə bu problemin olmadığından bunun ilə çox köhnə kodları müəyyənləşdirə bilərsiniz.
64
64
65
65
66
-
## External scripts
66
+
## Kənar skriptlər
67
67
68
-
If we have a lot of JavaScript code, we can put it into a separate file.
68
+
Çoxlu JavaScript kodu olduqda bu kodu ayrı faylda saxlamaq mümkündür.
69
69
70
-
Script files are attached to HTML with the `src`attribute:
70
+
Skript faylları HTML-ə `src`atributu ilə qoşulurlar:
71
71
72
72
```html
73
73
<scriptsrc="/path/to/script.js"></script>
74
74
```
75
75
76
-
Here, `/path/to/script.js`is an absolute path to the script from the site root. One can also provide a relative path from the current page. For instance, `src="script.js"`would mean a file `"script.js"`in the current folder.
76
+
Burada, `/path/to/script.js`dəyəri saytın kökündən absolut yol ilə skript faylına istinad edir. Əlavə olaraq, cari səhifəyə nisbi yerləşən fayla da istinad etmək olar. Məsələn, `src="script.js"`dəyəri `"script.js"`faylının cari direktoriyada olması deməkdir.
77
77
78
-
We can give a full URL as well. For instance:
78
+
Biz, skriptin mənbəsini tam URL ilə də təyin edə bilərik. Məsələn:
Bir neçə skripti qoşmaq üçün bir neçə təqdən istifadə edin:
85
85
86
86
```html
87
87
<scriptsrc="/js/script1.js"></script>
@@ -90,29 +90,29 @@ To attach several scripts, use multiple tags:
90
90
```
91
91
92
92
```smart
93
-
As a rule, only the simplest scripts are put into HTML. More complex ones reside in separate files.
93
+
Qayda olaraq yalnız çox sadə skriptləri HTML faylında saxlayın. Daha mürəkkəb skriptləri fərqli fayllarda saxlayın.
94
94
95
-
The benefit of a separate file is that the browser will download it and store it in its [cache](https://en.wikipedia.org/wiki/Web_cache).
95
+
Skripti kənarda saxladıqda brauzer, faylı yükləyib öz [kəşində](https://en.wikipedia.org/wiki/Web_cache) saxlayacaq.
96
96
97
-
Other pages that reference the same script will take it from the cache instead of downloading it, so the file is actually downloaded only once.
97
+
Eyni skripti yükləyən digər səhifələr skripti yükləmək əvəzinə kəşdən oxuyacaq. Bu səbəbdən skript faylı yalnız bir dəfə yüklənəcək.
98
98
99
-
That reduces traffic and makes pages faster.
99
+
Bu, trafiki azaldaraq səhifəni tezləşdirəcək.
100
100
```
101
101
102
-
````warn header="If `src`is set, the script content is ignored."
103
-
A single `<script>`tag can't have both the `src`attribute and code inside.
102
+
````warn header="`src`atributu təyin edildikdə skriptin kontenti sayılmır."
103
+
Tək `<script>`təqinin həm `src`atributu, həm də daxili kodu ola bilməz.
104
104
105
-
This won't work:
105
+
Aşağıdakı kod işləməyəcək:
106
106
107
107
```html
108
108
<script*!*src*/!*="file.js">
109
-
alert(1); //the content is ignored, because src is set
109
+
alert(1); //src təyin edilib deyə kontent sayılmır
110
110
</script>
111
111
```
112
112
113
-
We must choose either an external `<script src="…">`or a regular `<script>`with code.
113
+
Biz ya kənar skripti yükləyən `<script src="…">`təqi, ya da kod ilə `<script>`təqini təyin edə bilərik.
114
114
115
-
The example above can be split into two scripts to work:
115
+
Yuxarıdakı nümunənin işləməsi üçün skriptləri ayrı-ayrı təqlərə ayırın:
116
116
117
117
```html
118
118
<scriptsrc="file.js"></script>
@@ -122,11 +122,11 @@ The example above can be split into two scripts to work:
122
122
```
123
123
````
124
124
125
-
## Summary
125
+
## Xülasə
126
126
127
-
- We can use a `<script>` tag to add JavaScript code to a page.
128
-
- The `type` and `language` attributes are not required.
129
-
- A script in an external file can be inserted with `<script src="path/to/script.js"></script>`.
127
+
- JavaScript kodunu səhifəyə əlavə etmək üçün `<script>` təqindən istifadə edə bilərik.
128
+
- `type` və `language` atributlarından istifadə etmək vacib deyil.
129
+
- Kənar faylda yerləşən skriptləri `<script src="path/to/script.js"></script>` təqi ilə yükləmək mümkündür.
130
130
131
131
132
-
There is much more to learn about browser scripts and their interaction with the webpage. But let's keep in mind that this part of the tutorial is devoted to the JavaScript language, so we shouldn't distract ourselves with browser-specific implementations of it. We'll be using the browser as a way to run JavaScript, which is very convenient for online reading, but only one of many.
132
+
Brauzer skriptləri və onların veb səhifə ilə interaksiyası haqqında öyrənilməli daha çox məlumat var. Lakin, dərsliyin bu hissəsinin JavaScript dilinə həsr olunduğu üçün biz brauzerə xas tətbiqlərə fokuslanmayacağıq. Biz JavaScript kodunu icra etmək üçün brauzerdən istifadə edəcəyik. Brauzerdən istifadə etdikdə icra olunan skriptləri onlayn oxumaq olur. Lakin, skriptləri başqa mühitlərdə də icra etmək mümkündür.
0 commit comments