469,289 Members | 2,156 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,289 developers. It's quick & easy.

How to use Include Files

Does Javascript support include files? I have some functions that I
need in 4 pages with Javascript. Can I somehow include that data by
using a general include file? All of the Javascript is not the same,
just some functions. So, I really have only one set to <SCRIPT>.....</

Much of that code is unique to the page, but some of the functions are
re-usable. Any way to include the reusable code.
Mar 25 '08 #1
1 1156
m...@mtekusa.com wrote:
One thing I am unclear on is this....Say I have the following in one

function {


some code which calls the above function


Then, I have this in the other page:

function {


some differnet code which calls the above function


Since the function is reusable, how do I include it between the
<SCRIPT... </SCRIPTheaders??
The reusable function needs to be placed in a separate file. Say 3
files in a same directory:


function showMessage(m) {

call from one.htm:

<script type="text/javascript" src="remote.js"></script>
<script type="text/javascript">

call from two.htm:

<script type="text/javascript" src="remote.js"></script>
<script type="text/javascript">
showMessage('Hello again');


Mar 26 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by atv | last post: by
5 posts views Thread by David Mathog | last post: by
1 post views Thread by ya man | last post: by
9 posts views Thread by chat | last post: by
2 posts views Thread by key9 | last post: by
16 posts views Thread by Chris Shearer Cooper | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.