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
This trick isn't used in modern JavaScript. These comments hid 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.
If we have a lot of JavaScript code, we can put it into a separate file.
68
-
69
-
Script files are attached to HTML with the `src` attribute:
68
+
腳本檔案可以通過 `scr` 屬性添加到 HTML 檔案中。
70
69
71
70
```html
72
71
<scriptsrc="/path/to/script.js"></script>
73
72
```
74
73
75
-
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.
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.
0 commit comments