I am using some common Javascript functions I wrote that are required in several pages. I would prefer to have the functions in a single .js file and link to this file from the required web pages. How do I link to such a file ? I tried the same method as linking to a Stylesheet file, but it is not working.

<Link Href="MainStyles.css" rel="Stylesheet" type="text/css">

This is working fine

<LINK HREF="GenJS.js" type="text/javascript">

This is not working.

The contents of the GenJS.js file is

<SCRIPT Language="Javascript">

function Gablu()
	alert ("Hullo") ;


When I am trying to refer to the function Gablu(), I am getting the error 'Object Required'

11 Years
Discussion Span
Last Post by aparnesh

Use the code given by stymiee; also, take the <SCRIPT Language="Javascript"> and </SCRIPT> tags out of the .js file... they are not needed in this case.


Plus you can safely do away with the language='javascript' attribute since Javascript is the default scripting engine for all browsers. Use this tag only when you are using two or more scripting languages. Eg. VBScript etc.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.