Javascript include

User avatar
Jezza
5StarLounger
Posts: 843
Joined: 24 Jan 2010, 06:35
Location: A Magic Forest in Deepest, Darkest, Kent

Javascript include

Post by Jezza »

I have a series of javascript functions stored in a javascript file called scripting.js.

Some of the functions refer to values declared as global variables in the main file whose values may change in time, I will be handing this integration over at some time and do not wish the person responsible for the system to have to access the scripting.js file as it will cause a risk of change. I therefore want to list my global variables in an external file that scripting.js can refer.

The main question is [how] can I link to an external js file from within scripting.js and if so how?
Jerry
I’ll be more enthusiastic about encouraging thinking outside the box when there’s evidence of any thinking going on inside it

User avatar
HansV
Administrator
Posts: 71500
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Javascript include

Post by HansV »

Regards,
Hans

User avatar
Jezza
5StarLounger
Posts: 843
Joined: 24 Jan 2010, 06:35
Location: A Magic Forest in Deepest, Darkest, Kent

Re: Javascript include

Post by Jezza »

Thanks for the speedy reply, maybe I should have stipulated that I need it called from within the js file itself and not from a HTML page
Jerry
I’ll be more enthusiastic about encouraging thinking outside the box when there’s evidence of any thinking going on inside it

User avatar
HansV
Administrator
Posts: 71500
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Javascript include

Post by HansV »

As far as I know, JavaScript itself doesn't have an include feature. Every "solution" I've seen depends on adding a script tag to the HTML page the JavaScript is run from, either manually or programmatically.
Regards,
Hans