iTech College - Internet Technology, Online Education, E-Learning, Technician Training, Tech Tutorials, Distance Education, Virtual Learning JavaScript Course: Embedding and including - www.itechcollege.com JavaScript Course: Embedding and including - www.itechcollege.com
Free Courses
HTML
JavaScript
CSS
ASP
PHP
JSP
C++
ASP.NET
SQL
AJAX
FTP
XML

courses > JavaScript > Embedding and including

Embedding and including

Let's first see a simple example:

     <html>
     <head>
     <title>This is a JavaScript example</title>
     <script language="JavaScript"> 
     <!-- 
     document.write("Hello World!");
     //-->
     </script> 
     </head>
     <body> Hi, man! </body>
     </html>

Usually, JavaScript code start with the tag <script language="JavaScript"> and end with the tag </script>. The code placed between <head> and </head>. Sometimes, people embed the code in the <body> tags:

     <html>
     <head></head>
     <body>
     <script>
     .....// The code embedded in the <body> tags.
     </script>
     </body>
     </html>

Why we place JavaScript code inside comment fields <!-- and //-->? It's for ensuring that the Scripts is not displayed by old browsers that do not suport JavaScript. This is optional, but considered good practice.The LANGUAGE attribute also is optional, but recommended. You may specify a particular version of JavaScript:

     <script language="JavaScript1.2">

You can use another attribute SRC to include an external file containing JavaScript code:

     <script language="JavaScript" src="hello.js"></script>

For example, the below is the code of the external file "hello.js":

     document.write("Hello World!");

The external file is simply a text file containing JavaScript code, and with the file name extension ".js". Note:
1. Including an external file only functions reliably across platforms in the version 4 browsers.
2. The code can't include tags <script language...> and </script>, or you will get an error message.



  Back to Index Page
 Next Page:  

Embedding and including
write and writeln
Document object
Message box
Variables and Conditions
Function
Event handler
Form
Link
Date
Window
Frame


Online Education, Online Training for Your Job, Distance Education, E-learning Programs for Your Career!Online Colleges, Online Universities, E-learning & Distance Education for Your Career! Easy Job Training & Online Courses.


   Email A Friend  
 
Earn Online Degree
for Your Job
I found a job after I earned an online degree!
Online classes for finding a Job. Online College, Online University, Degrees, E-learning school, online certificate Earn your
online degree now!
Online Training
for Good Job
Why I work so hard but earn so little? Why I cannot find a high paying job?
Online training for a Good Jobs. Online Degree, E-learning school, online certificate Go to
online school now!

Copyright ©2024, itechcollege.com. All rights reserved
iTechCollege | About iTech | Contact iTech