p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Javascript (http://p2p.wrox.com/forumdisplay.php?f=85)
-   -   External JS files (http://p2p.wrox.com/showthread.php?t=11728)

Ben Horne April 12th, 2004 04:08 PM

External JS files
Hi all,

If I wanted to put all of my Javascript code in a separate JS file and reference that in a web page, how would I need to reference the JS file?

Ben Horne
Madison Area Technical College student


Go there. I have a lot of awesome photos that I rendered myself

"There are two kinds of people in the world: Those who claim to be Flash junkies and those who actually are Flash junkies"

PortGuy April 12th, 2004 04:15 PM

Simple, Ben, as follows:

<script language="JavaScript" src="/my_global_dir/my_global_js_file.js"></script>

Within your external JavaScript file, you do not use the <script> tag, but simply type the code without the opening and closing <script> tags.

And by the way, most developers recommend using external JS files when you are re-using many of the functions.

Snib April 12th, 2004 04:15 PM

I like using external .js files because when you want to change the script for a web page, modifying the .js document is like changing all the pages that link to it at once.

The above solution should work perfectly for you.



P2P Member

beetle_jaipur July 25th, 2008 02:00 AM

thanks friend, that little statement "you do not use the <script> tag" helped me to resolve my error



All times are GMT -4. The time now is 03:18 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.