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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I reference external js from inside another external js?

Status
Not open for further replies.

bthale

Programmer
Oct 31, 2001
108
US
I know this can be done with the script tags in html pages, but can it be done from one js file to another without html code or page?
 
This doesn't make any sense. JS cannot normally be run outside a browser. You would need a JS run time to do so.

You might be thinking of JScript or even VBscript, but not Javascript.

Even if you are using a runtime for Js, there is no actual include function in JS.

There are some ways too fake an include function, but they rely on actual HTML elements. Mainly the script tags.

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
Hi

Personally I have [tt]js[/tt] ( Mozilla interpreter ), [tt]jsc[/tt] ( WebKit interpreter ) and [tt]seed[/tt] ( GObject JavaScriptCore bridge ) installed, so I can do it with JavaScript :
Code:
[blue]master #[/blue] cat js1.js 
load('js2.js')

foo()

[blue]master #[/blue] cat js2.js 
function foo()
{
  print('bar')
}

[blue]master #[/blue] js js1.js 
bar

[blue]master #[/blue] jsc js1.js 
bar

[blue]master #[/blue] cat js1b.js 
foons=imports.js2

foons.foo()

[blue]master #[/blue] seed js1b.js 
bar
Of course, if this is not what the OP wants, he share more details about all this.

Feherke.
 
I am using Sellenium for automated test script and there is a feature where you can write your own commands in javascript. My problem is it gives me an error saying the Sellenium object is not defined. It is defined elsewhere so I wanted to include or reference this js file in my external js file. So it's not really browser based although it does seem to be running in the browser.


I was looking for syntax to reference another js file, if that's possible.

Will the load() method work?
 
HI folks. I finally got Selenium to load my js file, and then I discovered there is Selenium forum here. Sorry I should have asked the question there.

Thanks for all help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top