A JavaScript program can be kept in html page under <script> JavaScript program </script> tag. We can place unlimited number of scripts in the html program in head or body section. |
Keeping JavaScript in head section |
If we want that the JavaScript program should be executed when it is called, then we should keep it in head section. |
How to keep JavaScript in head section of a HTML file: |
<html>
<head> <script type=”text/JavaScript”> script code </script> </head> </head> |
This is just syntax (how & where to type), we will learn it in detail after learning functions. |
Keeping JavaScript in body section |
If we want that the script should be executed when the page loads then we should keep the JavaScript program in body section. |
How to keep JavaScript in body section of a HTML file : |
<html>
<head> </head> <body> <script type=”text/JavaScript”> script code </script> </body> </head> |
This is just syntax (how & where to type) we will learn it in detail after learning variables. |