Home > Javascript > Declaring JavaScript Code

Declaring JavaScript Code

This article will guide you to declaring 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

Your email:

 


Example – Declare JavaScript Code

<html>
<head>
<script type="text/javascript">
  document.write("This is from inline HTML code.")
</script>
</head>
<body>...</body>
</html>


Custom Search

Popular Articles:

Share and Enjoy:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • email
  • IndianPad
  • LinkedIn
  • Live
  • MySpace
  • Netvibes
  • RSS
  • Technorati
  • Yahoo! Bookmarks
  • Yahoo! Buzz
  • Reddit
  • Add to favorites
  • PDF
  • Twitter
Categories: Javascript Tags:
  1. No comments yet.
  1. No trackbacks yet.