728x90
SMALL
Javascript
Insert directly into HTML document
This is a method to create a <script> tag in an HTML document and put the code in it.
<script>
alert ("Hello");
</script>
This method is useful if you use JavaScript for some pages or if your JavaScript code is short.
Create and load a script file
How to link to an HTML document after creating a file containing JavaScript code.
Create a file with the following content and save it as hello.js. (The extension of the script file is js.)
alert ("Hello");
Then put the following code in your HTML document:
<script src="hello.js"></script>
In the value of src, describe the name of the script file to connect with the path.
This method is useful when you want to apply the same JavaScript code to many HTML documents or when the JavaScript code is long.
728x90
LIST
'Javascript' 카테고리의 다른 글
[JavaScript] JavaScript/operator/typeof operator (0) | 2022.08.01 |
---|---|
[Javascript] JavaScript / operator / comparison operator (0) | 2022.07.29 |
[Javascript] JavaScript / data type / string (0) | 2022.07.29 |
[Javascript] Add a comment (0) | 2022.07.27 |
[Javascript] How to put the syntax (0) | 2022.07.27 |