Way To Adding Javscript

S
0
Document

Way Of Adding Javascript

  1. To incorporate JavaScript into your webpage, it is essential to utilize the <script> tag.
  2. Inline
    1. Inside Head Tag
    2. <head>
         <title> page title </title>
         <script type="text/javascript">
            document.write('hello');
         </script>
      </head>
    3. Inside Body Tag
    4. <body>
         <h1> heading </h1>
         <script type="text/javascript">
            document.write('hello');
         </script>
      </body>
  3. External File
    1. Inside Head Tag
    2. <head>
         <title> page title < /title>
         <script src="file.js" type="text/javascript">
         </script>
      </head>
    3. Inside Body Tag
    4. <head>
         <title> page title </title>
         <script src="file.js" type="text/javascript">
         </script>
      </head>

Script Tag In Javascript

  1. <script> :- Opening Script Tag
  2. src :- The src attribute of the <script> tag is used to specify the location of the script file.
  3. file.js :- This is our JavaScript file, where 'file' represents the file name and '.js' denotes the JavaScript extension.
  4. 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.
  5. text/javascript :- It denotes the specific document type or language in use.
  6. document.write('hello'); :- It function as a mechanism employed to showcase or exhibit data.

Post a Comment

0Comments

hiiii, hello dear how are you ?

Post a Comment (0)