eHow launches Android app: Get the best of eHow on the go.

How To

How to Include an External Javascript File in your HTML Website Page

Member
By Mike
User-Submitted Article
(0 Ratings)

Javascript is a very popular scripting language that allows web developers to make a website more interactive.

As you probably know by now HTML is a very simple markup language where anyone can create a webpage in a matter of seconds...literally!

You have two ways to incorporate the use of javascript with your html web page. One way is to include the scripting code in the same file as the HTML and the second way, which what this tutorial is all about, is to create an external file that contains the javascript code and then create code within your html file to include it.

Difficulty: Easy
Instructions
  1. Step 1

    The first step is to create a javascript file. Open notepad or some other text editor and create a simple function. Then save the file as "myfirstjavascript.js". Make sure it has the .js extentions. Take a look at the picture associated with this step for the sample javascript function.

  2. Step 2

    With our sample javascript file in place we now have something to include in our html document. At the very top of your html document write the code that is shown in the picture associated with this step. eHow does not allow javascript code within steps.

  3. Step 3

    Now anywhere within your HTML document you can make a call to the functions and code within that external javascript file. Using external javascript files makes it much easier to reuse code through various HTML pages without writing the same code over and over.

Post a Comment

Post a Comment
  • Have you done this? Click here to let us know.
I Did This

Related Ads

Computers
Alexia Petrakos,

Meet Alexia Petrakos eHow's Computers Expert.

Get Free Computers Newsletters

Copyright © 1999-2009 eHow, Inc. Use of this web site constitutes acceptance of the eHow Terms of Use and Privacy Policy.   en-US Portions of this page are modifications based on work created and shared by Google and used according to terms described in the Creative Commons 3.0 Attribution License.

eHow Computers
eHow_eHow Technology and Electronics