Wrox Programmer Forums
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old April 12th, 2004, 04:08 PM
Friend of Wrox
Join Date: Sep 2003
Posts: 451
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Ben Horne
Default 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"
Ben Horne
I don\'t want to sound like I haven\'t made any mistakes. I\'m confident I have.

Most likely using FireFox and concocting my next Macromedia Flash project
Snibworks Forums Moderator

Welcome to the New Age
Old April 12th, 2004, 04:15 PM
Authorized User
Join Date: Mar 2004
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts

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.

Old April 12th, 2004, 04:15 PM
Friend of Wrox
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts

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
Old July 25th, 2008, 02:00 AM
Authorized User
Join Date: Feb 2006
Posts: 67
Thanks: 7
Thanked 0 Times in 0 Posts
Send a message via Yahoo to beetle_jaipur

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



Similar Threads
Thread Thread Starter Forum Replies Last Post
external.js not executed cyrus67 Javascript 2 November 17th, 2006 10:29 AM
refreshing external js file fs22 Javascript How-To 1 June 17th, 2004 05:02 PM
Advice on Dynamically assigning external js file fs22 Javascript 9 June 10th, 2004 05:26 PM
Dynamically assign external js file fs22 Javascript How-To 1 May 21st, 2004 05:22 PM
External JS Files koneruvijay VS.NET 2002/2003 4 February 27th, 2004 07:28 AM

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