HTML Introduction | HTML Extensions | HTML JavaScript
What is JavaScript?
JavaScript is an object-based scripting language. With HTML, you can write web content; with CSS, you can design the web; and with JavaScript, you can implement web behavior. JavaScript is mainly used in web browsers, but with frameworks such as Node.js, it can also be used for server-side programming. Most web browsers included on computers, smartphones, and similar devices have a built-in JavaScript interpreter.
script element
The script element is used to define scripts to use on the web page. You can write scripts directly inside the script element or specify the address of an external script file as the src attribute value.
<script>
document.getElementById("text").innerHTML = "이것이 자바스크립트다!";
</script>
You can also change HTML styles with JavaScript.
document.getElementById("text").style.fontSize = "25px";
document.getElementById("text").style.color = "red";
document.getElementById("text").style.backgroundColor = "yellow";
noscript element
The noscript element is used to set the text shown to users who use a web browser that does not support scripts. The noscript element can contain any element that can appear inside the body element of a normal HTML document.
<script>
document.getElementById("text").innerHTML = "이것이 자바스크립트다.";
</script>
...
<noscript>이 웹 브라우저는 자바스크립트를 지원하지 않습니다!</noscript>
External JavaScript
The method using external JavaScript lets you manage HTML and JavaScript separately. Include JavaScript with the <script> tag inside the <head> tag of every web page to which JavaScript should be applied. Recently, it is sometimes placed at the bottom of the body because of web page loading issues.
<script type="text/javascript" src="/external_javascipt.js"></script>