Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: Standard routines in separate js-files


Message #1 by kdekker@h... on Wed, 7 Mar 2001 15:58:48
I copied your code and fixed your typo (the second Script1.js -->
Script2.js) and it worked fine

-----Original Message-----
From: kdekker@h... [mailto:kdekker@h...]
Sent: Wednesday, March 07, 2001 10:59 AM
To: javascript
Subject: [javascript] Standard routines in separate js-files


Hi,

I should like to have standard routines in separate js-files and reuse 
them. Like this simple example. It is for use with IE 5.5 only.

File Script.htm

<html>
  <script language="JavaScript" src="Script1.js"></script>
  <script language="JavaScript" src="Script1.js"></script>
  <body>
    <button onclick="alert(Script1());">Click</button>
  </body>
</html>

File Script1.js

function Script1()
{ return Script2();
}

File Script2.js

function Script2()
{ return "Script2";
}

This does not work. Function Script2 is not known in file Script1.js.

Note: When I use  <script language="JavaScript" src="Script1.js"/>
without </script> then I get another error. 

Any solution?
Thanks,
Kees



  Return to Index