JavaScript is a lightweight, interpreted programming language. It is designed for creating network-centric applications.
JavaScript is complementary to and integrated with HTML. The JS statements are placed within the <script> ... </script> tags in a web page. You can place the <script> tag containing JS code anywhere in the web page, but the preferred way to keep it within the <head>...</head> tags.
JavaScript is complementary to and integrated with HTML. The JS statements are placed within the <script> ... </script> tags in a web page. You can place the <script> tag containing JS code anywhere in the web page, but the preferred way to keep it within the <head>...</head> tags.
The
<script> tag alerts the browser to interpret all the text between them as a script. The <script> tag has two important attributes: (1) language: specifies what scripting language you are using. (2) type:
specifies the Internet media type of a script. For
JavaScript, the media type is "text/javascript".
So the JS segment may look like:
<script
language="javascript" type="text/javascript"> ……. </script>
language="javascript" type="text/javascript"> ……. </script>
<script
type="text/javascript"> ……. </script>
<script>
..... </script>
Modern
browsers support anyone of the above.
Your First
JavaScript program:
<html>
<body>
<script
type="text/javascript">
document.write("Hello World!")
document.write("Hello World!")
</script>
</body>
</html>
Above code
will display following result:
Hello World!