Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 12th, 2004, 04:08 PM
Friend of Wrox
 
Join Date: Sep 2003
Location: Madison, Wisconsin, USA.
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

-------------------------
http://community.webshots.com/user/valerian114

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
Reply With Quote
  #2 (permalink)  
Old April 12th, 2004, 04:15 PM
Authorized User
 
Join Date: Mar 2004
Location: New York, NY, USA.
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Simple, Ben, as follows:

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

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.


Reply With Quote
  #3 (permalink)  
Old April 12th, 2004, 04:15 PM
Friend of Wrox
 
Join Date: Nov 2003
Location: , , .
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

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.

HTH,

Snib

P2P Member
<><
Reply With Quote
  #4 (permalink)  
Old July 25th, 2008, 02:00 AM
Authorized User
 
Join Date: Feb 2006
Location: jaipur, rajasthan, India.
Posts: 67
Thanks: 7
Thanked 0 Times in 0 Posts
Send a message via Yahoo to beetle_jaipur
Default

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

thanks

ashok

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



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


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