including other .js files in my script file 
Author Message
 including other .js files in my script file

Hello,

Is there anyway to include an .js file in another .js file.

For example, I want to use my string utiliy js file (string.js) in my
main.js.

I know that I can do it by including it in the HTML file (<script
src="string.js">...).

Do you have any idea....

Thanks!

Laurent Allardin



Sun, 07 Jul 2002 03:00:00 GMT  
 including other .js files in my script file

You'll have to use 2 <script> elements in the page...

<script ... src="string.js"></script>
<script ... src="main.js"></script>

Now functions in main.js can call functions in string.js.

It would be different if jscript/javascript as a language had an "include" function/directive, but it doesn't.

--
Michael Harris

  Hello,

  Is there anyway to include an .js file in another .js file.

  For example, I want to use my string utiliy js file (string.js) in my
  main.js.

  I know that I can do it by including it in the HTML file (<script
  src="string.js">...).

  Do you have any idea....

  Thanks!

  Laurent Allardin



Sun, 07 Jul 2002 03:00:00 GMT  
 including other .js files in my script file
hi,

no, since js has no include feature, then make one..

function include(url){
    document.writeln(
     '<scr', 'ipt language="javascript" src="', url ,
     '" type="text\/javascript"><\/scr', 'ipt>');
    return 1 }

then from your main.js,call the another script file like;
include("string.js");

this works fine in MSIE 4+and Netscape 4+
havent tested it on earlier browsers..

ok, good luck.
thomas

_________________________________________________________

 http://crossprobe.jet.st
_j_E_t_._s_p_a_g_h_e_t_t_i_._i_n_d_u_s_t_r_i_e_s_.______________

Service Informatique Novexco skrev i meddelandet ...

Quote:
>Hello,

>Is there anyway to include an .js file in another .js file.

>For example, I want to use my string utiliy js file (string.js) in my
>main.js.

>I know that I can do it by including it in the HTML file (<script
>src="string.js">...).

>Do you have any idea....

>Thanks!

>Laurent Allardin



Sun, 07 Jul 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Include JS file from JS file

2. including js file inside an js file

3. Including PS files in others

4. Accessing variables from included js file

5. Including an external .js file via JScript

6. Including JS files

7. Help:include js file

8. including multiple js files...

9. Include a js file

10. include .js files

11. IE 4 and including js-files

12. Include JavaScript file in another include file

 

 
Powered by phpBB® Forum Software