Sagewire Logo

How do I call a function from another .js file?

3 Message(s) by 2 Author(s) originally posted in javascript


From: Snoopie Date:   Thursday, August 03, 2006
i've 2 .js file s, mpi.js and function s.js
the functions.js file contains common functions that I reference from
my web pages. I have a function in mpi.js that needs to call one of
the functions from functions.js but I dont know how to do this.
if memory serves me in JAVA you had to use the import statement, but
that doesn't appear to work in this case.

Snoopie


From: Snoopie Date:   Thursday, August 03, 2006
wrote in message:

i have 2 .js files, mpi.js and functions.js
the functions.js file contains common functions that I reference from
my web pages. I have a function in mpi.js that needs to call one of
the functions from functions.js but I dont know how to do this.
if memory serves me in JAVA you had to use the import statement, but
that doesn't appear to work in this case.
Snoopie



ha, I answered my own question

the code is as follows

in the mpi.js I just needed to add

// include functions.js
document.write("<script language='JAVAscript' type='text/JAVAscript'
src='scripts/functions.js'>
</script>");

note that I keep my scripts in a subfolder called scripts
I hope this helps out someone else

Snoopie


From: tia Date:   Saturday, January 20, 2007
wrote in message:
wrote in message: I have 2 .js files, mpi.js and functions.js
the functions.js file contains common functions that I reference from
my web pages. I have a function in mpi.js that needs to call one of
the functions from functions.js but I dont know how to do this.
if memory serves me in JAVA you had to use the import statement, but
that doesn't appear to work in this case.

Snoopie
ha, I answered my own question
the code is as follows
in the mpi.js I just needed to add
// include functions.js
document.write("<script language='JAVAscript' type='text/JAVAscript'
src='scripts/functions.js'>
</script>");
note that I keep my scripts in a subfolder called scripts I hope this helps out someone else
Snoopie


Just want to add this - do not make the mistake of thinking that
JAVAscript has anything at all to do with JAVA. It does not.



Next Message: Retrieve button value


Blogs related to How do I call a function from another .js file?

Introduction to Javascript Tutorial
Those of you who opt to do both Java and JavaScript tutorials are going to notice ... JS file. If you are linking externally you would call it up like this in your ... Functions and Methods A JavaScript function is quite similar to a ...

Patterns and Practices In JavaScript
Moreover unlike c# or even java its complied at run time more specifically ... file with the .js extension and link the web page with the .js file. ... You need only call the function and know that the correct object will be returned. ...

JavaScript debugging tips (for Mustang context)
Mustang (Java SE 6) is co-bundled with Mozilla Rhino based JavaScript engine as an example implementation for ... Functions can be called by apply or call functions. ... When running the Test class with the following t.js script file, ...

File Extensions
DRV Device Driver (Required to make a device function) ... EXC Exclude file for Optimize (do not process, QEMM) ... JAR Java ARchive (a compressed file for applets and related files) ... PFK Programmable function keys (XTreePro) ...

JSON - Serialized Language and Cross-Domain Scripting
That means you convert your class or array in PHP, Java, . ... the aspx page as library, and call the function to obtain JSON object. ... You do not need to wrap in JS function if you use in another language like PHP, Python, etc... ...

links for 2006-12-01
Top 10 custom JavaScript functions of all time. (tags: zedomax ajax blog code Development firefox inspiration Java utilities tips resources javascript webDesign). 30 Things That Take 30 Seconds Each: Which Will You Do To Change The ...


Programming | Sports | Autos

copyright 2006
Valid XHTML 1.0 Transitional