Forum Moderators: open

Message Too Old, No Replies

including js file inside js file

Is it possible

         

AjiNIMC

6:47 pm on Jun 23, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi,

I have a js file say 1.js and now from 1.js I need to include another file http://example.com/2.js, is it possible using js.

I cant use html as I am using xul.

It gives an error
Error: syntax error
Source File:
Line: 1
Source Code:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">

In other words how to include an external file(from some other server) inside another js?

Aji

[edited by: BlobFisk at 8:45 am (utc) on June 24, 2005]
[edit reason] Examplified URL [/edit]

JAB Creations

7:46 pm on Jun 23, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've never tried this and have no clue if it would work. You could try to document.write it but I'm not sure the browser or at least some browsers would care to execute a JS file written to HTML from another JS file. Why would you try loading a JS file from another JS file anyway?

kaled

11:20 pm on Jun 23, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I forget the details, but someone posted a solution (for html/xhtml) that involved using document.write() to create <script> tags.

Once again this glaring omission of basic functionality proves that the people who set internet standards are not very smart.

Kaled.

AjiNIMC

3:54 am on Jun 24, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I was planning to hook php throuhgh js but js is called from xul. It looks like I will have to use xmlhttprequest to survive.

Thanks
Aji