Way Of Adding Javascript
- To incorporate JavaScript into your webpage, it is essential to utilize the <script> tag.
-
Inline
- Inside Head Tag
- Inside Body Tag
<head>
<title> page title </title>
<script type="text/javascript">
document.write('hello');
</script>
</head><body>
<h1> heading </h1>
<script type="text/javascript">
document.write('hello');
</script>
</body> -
External File
- Inside Head Tag
- Inside Body Tag
<head>
<title> page title < /title>
<script src="file.js" type="text/javascript">
</script>
</head><head>
<title> page title </title>
<script src="file.js" type="text/javascript">
</script>
</head>
Script Tag In Javascript
- <script> :- Opening Script Tag
- src :- The src attribute of the <script> tag is used to specify the location of the script file.
- file.js :- This is our JavaScript file, where 'file' represents the file name and '.js' denotes the JavaScript extension.
- type :- The type attribute of the <script> tag is optional and can be used to specify the scripting language being used, but it is not mandatory to include.
- text/javascript :- It denotes the specific document type or language in use.
- document.write('hello'); :- It function as a mechanism employed to showcase or exhibit data.
hiiii, hello dear how are you ?