Welcome to WebmasterWorld Guest from 54.145.44.134

Forum Moderators: open

Message Too Old, No Replies

External JS question

Little help with external JavaScript please...

     

Nick_W

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

WebmasterWorld Senior Member nick_w is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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

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

10+ Year Member



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

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

WebmasterWorld Senior Member nick_w is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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

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

WebmasterWorld Administrator jatar_k is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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

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

WebmasterWorld Senior Member macguru is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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

Nick_W

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

WebmasterWorld Senior Member nick_w is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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

Nick

Macguru

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

WebmasterWorld Senior Member macguru is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Good idea! Thanks for sharing.

tedster

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

WebmasterWorld Senior Member tedster is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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

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

WebmasterWorld Senior Member nick_w is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Right, thanks everyone ;)

Nick

 

Featured Threads

Hot Threads This Week

Hot Threads This Month