Declaring JavaScript Code
This article will guide you to decalring javascript code in your html/server side programming code.
- JavaScript can be used either directly in the HTML page or in a separate external file
- The external file will be importing in the Web file. The external file should have .js extension
- If you are planning to write your JavaScript code inside the web page then you will need to include the tag inside your web page
- But if you are using a separate file then you will have to include the js file using
- Usually the include code are written in the tag but you can insert it wherever you want. However it is recommend to write all the javascript includes in the tag. This way your JavaScript code will be differentiated from the HTML/Programming code and furthermore your HTML page will be easier to read and understand
Example - Declare JavaScript Code
<html> <head> <script type="text/javascript"> document.write("This is from inline HTML code.") </script> </head> <body>...</body> </html>
Similar Posts
Did you enjoy this post? Why not leave a comment below and continue the conversation, or subscribe to my feed and get articles like this delivered automatically to your feed reader.


Comments
No comments yet.
Leave a comment