Welcome to WebmasterWorld Guest from 54.225.47.124

Forum Moderators: open

Message Too Old, No Replies

JavaScript Tags

multiple external scripts called from 1 tag?

     
7:20 am on Feb 17, 2002 (gmt 0)

Moderator from US 

WebmasterWorld Administrator keyplyr is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Sept 26, 2001
posts:9294
votes: 450


Can multiple external JavaScripts, including one with a different lang type, be called from inside one tag? In other words, can this:

<script type="text/javascript" language="JavaScript"
src="/scripts/script1.js"></script>
<script language="JavaScript" type="text/javascript" src="/scripts/script2.js"></script>
<script language="JavaScript" src="/scripts/script3.js"></script>
<script language="JavaScript" type="text/javascript" src="/scripts/script4"></script>
<script language="JavaScript1.2" type="text/javascript"
src="/scripts/script5.js"></script>

... be written something like:

<script type="text/javascript"
language="JavaScript"
src="/scripts/script1.js" ;
src="/scripts/script2.js" ;
src="/scripts/script3.js" ;
src="/scripts/script4.js" ;
language="JavaScript1.2"
src="/scripts/script5.js"></script>

and if so, can it be even more concise?

12:59 pm on Feb 17, 2002 (gmt 0)

Full Member

10+ Year Member

joined:May 16, 2001
posts:287
votes: 0


No. One source (SRC) attribute per tag only.

To combine javascripts, put all of the javascript into a single .js file.

Alternately you can 'fudge' it by creating a javascript to write in all the other javascript tags.

Ammon Johns

8:54 pm on Feb 17, 2002 (gmt 0)

Moderator from US 

WebmasterWorld Administrator keyplyr is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Sept 26, 2001
posts:9294
votes: 450


Terrific,

How would I seperate the scripts if they were all on the one external file?

10:58 pm on Feb 17, 2002 (gmt 0)

Full Member

10+ Year Member

joined:May 16, 2001
posts:287
votes: 0


If they use the same language and version, there is no need to separate them at all, just define all the functions for all the scripts in one single big bite.

In other words, paste the contents of each .JS file, one after the other, into a single .JS file.

To fudge it just use one external JavaScript that uses the write() method to write-in all the other JavaScript calls

e.g.

document.write('<SCRIPT LANGUAGE="JavaScript" SRC="scripts/script1.js"> </SCRIPT>');
document.write('<SCRIPT LANGUAGE="JavaScript" SRC="scripts/script2.js"> </SCRIPT>');
document.write('<SCRIPT LANGUAGE="JavaScript" SRC="scripts/script3.js"> </SCRIPT>');
document.write('<SCRIPT LANGUAGE="JavaScript" SRC="scripts/script4.js"> </SCRIPT>');

1:59 am on Feb 18, 2002 (gmt 0)

Moderator from US 

WebmasterWorld Administrator keyplyr is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Sept 26, 2001
posts:9294
votes: 450


That's working just fine Black_Knight
Thanks again
8:16 am on Mar 5, 2002 (gmt 0)

Full Member

10+ Year Member

joined:May 16, 2001
posts:287
votes: 0


Glad to have been of help.