homepage Welcome to WebmasterWorld Guest from 50.19.33.5
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld
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...
Nick_W




msg:1491311
 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">
</script>

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...

Nick

 

gsx




msg:1491312
 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.

Nick_W




msg:1491313
 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?

Nick

jatar_k




msg:1491314
 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.

Macguru




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

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

Nick_W




msg:1491316
 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....

Nick

Macguru




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

Good idea! Thanks for sharing.

tedster




msg:1491318
 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>

Nick_W




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

Right, thanks everyone ;)

Nick

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.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved