Reference js file from another js file


Is it possible to reference the functions from one js file in another js file?
Any help is greatly appreciated.
11/7/2004 12:50:03 PM 24353 articles. 1 followers. Follow

3 Replies

Similar Articles

[PageSpeed] 13

Hey there,

Try to include it with the include directive, that is put the following in your js file
<!-- #include file=""-->
really, i didnt try it, but it should work, let me know if it works
The best glimpse of heaven is on the way into hell ;)
11/7/2004 1:11:04 PM
Assuming that you are using the javascript in a webpage, if you have references to both files then you should be able to reference functions from one file in another.

Use caution nesting #include statements, as there is a performance disadvantage in doing so.
||| Kristopher Cargile
11/7/2004 4:59:15 PM

No you cannot add .js file in .js file. But what you can do is, include both the file in same html/ or scripting page, it will work for your.

New Generation Systems


11/8/2004 5:57:54 PM

Similar Artilces:

Importing a .js file in another .js file......
Hello,I am having two javascript files. i want to use the function of 2nd javascript file into my 1st javascript file, How to do this, ??? In CSS if we want to use another css file then we can do it with @import but how to do the same in case javascript files....?????Prashant Here is one way to do it: Inside your first javascript file, you could have this function:function include_dom(script_filename) { var html_doc = document.getElementsByTagName('head').item(0); var js = document.createElement('script'); js.setAttribute('language', 'javascript...

Referencing another js file in an external js file
HiI'm trying to do something simple all I need to do is to reference another javascript file inside a javascript file. Is there an "include" statement that I can use.Many thanks no , but you can write document.write('<script src="path" type="text\javascript" ></script>');SHASHANK BHIDECAPGEMINI INDIA"THE ROAD TO SUCCESS IS ALWAYS UNDER CONSTRUCTION MARK MY RESPONSE AS ANSWER TO HELP ME BUILD IT :)"  ok I had a feeling that was the case, no probs and cheers. Hi, Its very simple. Iin the  page where are referring...

referencing .js files from withen another .js file
Hi: How can I include a reference to a js file to use for objects in another js file im looking for the code equivalent to "import" in, or "include" in c++ etc Thanks a lot, HF As far as I know there is no way to do it. All scripts should be referenced from hosting page and rendered in order of appearance. You can use objects from script already rendered.Leon LangleybenMCSD, ASP.NET MVPBlog I've seen code in .js files that does something like: document.write("<scr" + "ipt language='javascript' src='<Your include file>'></...

how to call js-file from js-file
Hello, I have wrote a FF-extension. The extension consists of a dialog. In the dialog file 'dlg.xul' I import a js-file with '<script type="text/javascript" src="chrome://helloworld/content/ Menue.js"/>' I can now call functions form 'Menue.js' out of the 'dlg.xul' (excellent). Now I want to import the js-file 'Tools.js' in the js-file 'Menue.js'. So I write '<script type="text/javascript" src="chrome://helloworld/ content/Tools.js"/>' at the beginning of the file 'Me...

Importing a .js file into a .js file
I have a javascript file that tries to call a function in another javascript file and it doesn't seem to be working.  Is there an 'import' or 'include' statement that I need to have.  The reason I'm not just putting the function in the file is that I want it to be available to a bunch of different javascript files. Thanks just call the function in the external javascript file as usual..the only condition is that both files must be included in the page.Home Is Where the Wind Blows

Include a .JS file into a .JS file
Hi,   Its very simple as below.   For example, Requirement is to add reference in File1.js to File2.js.   document.write("<script type='text/javascript' src='../JS/File2.js'></script>");  All you need to take care is, the source path must be relative to the Page, rather than to the File1.js    Thanks & Regards, Arun Manglick || Senior Tech Lead ||  Arun Manglick  Can it not be done like this :include('myFile1.js');  inclu...

How to include a js in another js file
Hello! I'm making a add-on extension and I have a problem to use functions that I defined in a javascript file. I have a directory Data and, in this directory, I have a file math_lib.js and a file cript.js. I'm trying to use the functions of math_lib.js in the cript.js, but this does not work. Someone has some idea? Thanks ...

Importing External JS files from an External JS file
 Hi Guys,I was trying to figure out a way to include an external js file from with in a js file.  Similar to a Import, or #include in C based languages.  I've tried writing a function that injects a <script> tag into the header of the document.  Here is what I'm trying:In test.js://function for including external *.js filesfunction inc(filename){ var head = document.getElementsByTagName('head').item(0); var script = document.createElement('script'); script.src = filename; script.type = 'text/javascript'; head.appendChil...

js file inside js file and syntax error
I have include this .js file inside another .js file like this.... document.write('<scr'+'ipt type="text/javascript" src="scripts/rollover.js" ></scr'+'ipt>'); And I am getting an error from this line and can't see where...     document.write("<td background=images/myImg.jpg'><a href='' target='_blank' onMouseOver='MM_swapImage('CO e-mail','',images/eImg.jpg',1)' onMouseOut='MM_swapImgRestore()'><img src=images/emailButton.jpg' alt=' CO e-mail' name='CO e-mail' width='157' height='50' border='0'></a></td>"); ...

Include Code-behind .js into another Code-behind .js file
I have a utility code-behind file in .js and I'm trying to add or reference to code in this file from another code-behind file in .js using the "import" feature. Anyone know how? Thanks... ...

Images, JS, and files references from CSS files don't deploy
Hello, I have had some problems getting some images or files to deploy.These directories or files are not set to "Exclude from Project", so how can I instruct VS which files are necessary when you do "Only deploy necessary files". I really don't want to deploy all the code, but some files VS just can't figure out on its own. Thanks,Josh ASP.NET/C# Developer Hi Josh How are you deploying the app? are you using a setup project? CheersGregorGregor SuttieMCSD, MCAD, MCSD.Net Thanks for the response Gregor, I am using FTP deployment to "publish" to testing server, wanti...

How can I reference a call to a function in another .js file ?
Following up on my previous message, the code I added needs to duplicate (add) the following 2 functions in navigator.js function prefClearCache(aType) function prefClearDiskAndMemCache() How can I invoke those 2 functions from pref-cache.js in navigator.js ? This would allow me to save adding a few lines to the overall code. Thanks, -- M@x Max wrote: > Following up on my previous message, the code I added needs to > duplicate (add) the following 2 functions in navigator.js > > function prefClearCache(aType) > function prefClearDiskAndMemCache() ...

Make js file to call some functions in client side
I do not like Java script but some times there is no another choice. In stead of writing Java script line by line every time, I like to create a JS file to store most often used methods and call this file through the RegisterScriptInclude() method. So far, I knew to add Alert("my message") to pop-up message box, can someone tell me where to find more useful Java script methods? Hi here are some examples hope this might help youmk...

how to call javascript function written within js file from server side code (code behind file) ?
Hi, I have js file containing all javascript functions required for my page. I am using ScriptManager.RegisterStartupScript to call javascript from code behind file. But for this i must  specify all javascript code from code behind file only. For eg.  if i use Page.ClientScript.RegisterStartupScript(typeof(System.String), this.ClientID + "_Init", strScript); where strScript contains <script>alert("hi");</script>, on page_Init event, this script is called. But when same script is embeded within a function  and i try to give function name in ...

Web resources about - Reference js file from another js file -

Wikipedia talk:Reference desk/Guidelines/Medical advice - Wikipedia, the free encyclopedia
I disagree with this implication that this section of the guideline represents the consensus. If you look at the last few years of discussion ...

New York Times Removes Reference to President Obama and Cable News
... — Noah Rothman (@NoahCRothman) December 18, 2015 The Times story was published Thursday, but by Friday morning, the reference to cable news ...

Reference Pricing tweak for Medicaid
Reference pricing is a common payment reform for commercial insurance. Common, non-urgent, deferrable procedures are prime candidates. Hip replacement ...

'Enough with the Viagra references,' says the CEO behind the first FDA approved drug to boost women's ...
... the Fortune Most Powerful Women Next Gen conference. But the reaction to the pill still confounded her. "Enough already with the Viagra references," ...

Zootopia Trailer Adds a Godfather Reference to Disney Film - Collider
Watch a new trailer for the Disney animated movie Zootopia, which takes place in a world inhabited by talking animals and features Jason Bateman ...

Hillary Clinton Ends Democratic Debate With A Star Wars Reference
The other day, President Obama ended his White House press conference with a reference to The [...]

Review: Klipsch X20i Reference In-Ear Headphones
These Klipsch X20i Reference In-Ear Headphones are pretty darn fantastic, and worth every penny.`

Kentucky Grade School Scrubs All References To Christianity In ‘Charlie Brown Christmas’
Kentucky Grade School Scrubs All References To Christianity In ‘Charlie Brown Christmas’

Disney Inundates General Hospital Episode With References To New Year's Eve College Football Playoff ...
ESPN says it isn’t worried about viewership for tomorrow’s college football playoff games on New Year’s Eve , but the degree to which TV viewers ...

Go Bang House by Takeru Shoji Architects references traditional Japanese farmhouses
A patio-like corridor surrounds the ground-floor rooms of this house by Takeru Shoji Architects, replicating traditional space in Japanese farmhouses ...

Resources last updated: 1/6/2016 12:14:19 PM