Friday, January 18, 2008

How to include one JavaScript file from another

Have one javascript file in header and one in footer for the whole
website, so that any changes in the script will reflects whole site.
Why you need two javascript ?
The header javascript must contains initalization or function code.The
footer javascript is for calling function code depends upon the existing
html elements. so that most error will reduce since the process is start
after all html element rendered.

Well, how can we include javascript from another?
Step 1: To include some JavaScript from an HTML file is simply:
<script language="JavaScript" type="text/javascript"

Step 2:Allow that external JavaScript file to cause another to be included, add
the following function to that first external JavaScript file:
// Function to allow one JavaScript file to be included by another.
// Copyright (C) 2006
function IncludeJavaScript(jsFile)
document.write('<script type="text/javascript" src="'
+ jsFile + '"></script>');

Step 3:Then to include a second JavaScript file simply add the line:

Note:The function logic is to write Sript Tags in the document.

No comments:

Adobe News