Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

include function

Status
Not open for further replies.

TheBestOfMe

Programmer
Apr 7, 2002
21
CA
I want to include a file containing functions in my javascript but I don't want to put a source to my javascript because I have other function that won't be in the file

How do I do
 
could you explain better? You are confusing.

What is it you are attempting to do exactly. What have you tried? And if you tried anything why wasn't it a viable solution. Gary Haran
 
I want to do something like this

<script language=JavaScript>

<!--#include file=&quot;funcion1.js&quot;-->
<!--#include file=&quot;funcion2.js&quot;-->

function TestSomething()
{
if ...
}

</script>

this include method is good for asp page, but I don't think is good in JavaScript.

I have functions used in a couple of pages but is not the only script in the page.
 
If your server does server-side includes, it'll work. Otherwise, you'll have to use:

<script language=&quot;javascript&quot; scr=&quot;funcion1.js&quot;></script>
<script language=&quot;javascript&quot; scr=&quot;funcion2.js&quot;></script>

to include the Javascript functions. And you won't use <script>... </script> tags in the external files, either, doing it this way.
 
this works perfectly.

the only thing is that the include must be on top of all others function.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top