Page 90 - HTML5
P. 90

The src attribute works like the href attribute on anchors: you can either specify an absolute or
        relative URL. The example above links to a file inside the same directory of the HTML document.
        This is typically added inside the <head> tags at the top of the html document


        Directly including JavaScript code


        Instead of linking to an external file, you can also include the JS code as-is in your HTML:


         <script>
         // JavaScript code
         </script>



        Including a JavaScript file executing asynchronously


         <script type="text/javascript" src="URL" async></script>


        Handling disabled Javascript


        It is possible that the client browser does not support Javascript or have Javascript execution
        disabled, perhaps due to security reasons. To be able to tell users that a script is supposed to
        execute in the page, the <noscript> tag can be used. The content of <noscript> is displayed
        whenever Javascript is disabled for the current page.


         <script>
           document.write("Hello, world!");
         </script>
         <noscript>This browser does not support Javascript.</noscript>


        Read Include JavaScript Code in HTML online: https://riptutorial.com/html/topic/3719/include-
        javascript-code-in-html





































        https://riptutorial.com/                                                                               74
   85   86   87   88   89   90   91   92   93   94   95