homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

External JS question
Little help with external JavaScript please...

 5:54 pm on Nov 3, 2002 (gmt 0)

Hi everone,

I'm putting a lot of JS in an external file and calling it like this:

<script language="javascript" src="js/external.js">

So, firstly: Is that the correct way to do it?

Secondly, I need to call some JS from another site. Can I do that from within my external JS? And of course, how do I do it?

In the code I'm working on it's just another <script src=> jobbie, I need to be able to do that from the external JS...

Many thanks...




 6:05 pm on Nov 3, 2002 (gmt 0)

Yes, that is the correct way, although you may want to add the language="JavaScript" (I think that is what it should be, you may need to double check), in case the browsers default scripting is something other than JavaScript (I don't know of any, but there could be some).

You can include other JavaScript from other sites by giving the full address ie. [?.com...]

Call from external? You mean as a library? You can include both, i.e. include the external first (as a function library), then include the internal ones that call the functions in the external.


 6:22 pm on Nov 3, 2002 (gmt 0)

Thanks.... I'm kinda with you ;)

So in my evternal file how would it look to call another script from another site?



 6:26 pm on Nov 3, 2002 (gmt 0)

I think you might have to have two script statements, I don't know if it will do it from within the external js file.

All I can say, slap the script tags for the other site into the external and test it. If it doesn't work put two sets of script tags on the original page.


 6:30 pm on Nov 3, 2002 (gmt 0)

Pardon my curiosity Nick_W, but why do need to do that?


 6:45 pm on Nov 3, 2002 (gmt 0)

hehe, it's an affiliate order form. I want to hide the JS call to an outside site from casual glance....



 7:54 pm on Nov 3, 2002 (gmt 0)

Good idea! Thanks for sharing.


 7:59 pm on Nov 3, 2002 (gmt 0)

Hey, Nick. The attribute
language="JavaScript" was introduced back when Netscape first introduced javascript -- but it is now deprecated in HTML 4.01. In fact, it's not supported at all in strict XHTML.

The recommended attribute is type="text/javascript". If you want deep backward compatibility, you can use them both:

<script src="file.js" language="JavaScript" type="text/javascript"></script>


 11:14 pm on Nov 3, 2002 (gmt 0)

Right, thanks everyone ;)


Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved