Reply
Externally Linking JS
Old 08-20-2006, 06:54 AM Externally Linking JS
dannyisonfire's Avatar
Average Talker

Posts: 22
Location: Hartlepool
I know its possible to link to a css file using:

<link rel="stylesheet" href="/style.css">

Is there a way to do this, to link to a .js file, and if so how.

Thanks.
__________________
www.dannyisonfire.com
dannyisonfire is offline
Reply With Quote
View Public Profile Visit dannyisonfire's homepage!
 
When You Register, These Ads Go Away!
Old 08-20-2006, 02:02 PM Re: Externally Linking JS
funkdaddu's Avatar
Web Design Snob

Posts: 636
<script type="text/javscript" src="yourscript.js"/>
funkdaddu is offline
Reply With Quote
View Public Profile Visit funkdaddu's homepage!
 
Old 08-25-2006, 09:13 AM Re: Externally Linking JS
JA1
JA1's Avatar
Novice Talker

Posts: 6
Name: Jane Alford
Location: Meath, Ireland
remember the trailing </script> otherwise your browser will stuff up!

<script type="text/javscript" src="yourscript.js"/></script>


J.
JA1 is offline
Reply With Quote
View Public Profile
 
Old 08-25-2006, 09:28 AM Re: Externally Linking JS
saadatshah's Avatar
Extreme Talker

Posts: 216
Name: Syed Saadat Ali
Location: Lahore, Pakistan
<script language="javascript" src="abc.js" type="text/javascript"></script>
__________________
Traffic School - Driver Ed - Defensive Driving - Texas Defensive Driving - Online Traffic School - Defensive Driving Course
If you have knowledge, let others light their candles in it.
saadatshah is offline
Reply With Quote
View Public Profile Visit saadatshah's homepage!
 
Old 08-25-2006, 10:11 AM Re: Externally Linking JS
JA1
JA1's Avatar
Novice Talker

Posts: 6
Name: Jane Alford
Location: Meath, Ireland
ah, such are the joys of cut 'n' paste
JA1 is offline
Reply With Quote
View Public Profile
 
Old 08-25-2006, 11:09 AM Re: Externally Linking JS
saadatshah's Avatar
Extreme Talker

Posts: 216
Name: Syed Saadat Ali
Location: Lahore, Pakistan
Not mentioning the script language may cause problem in old browsers I guess what you say JA 1
__________________
Traffic School - Driver Ed - Defensive Driving - Texas Defensive Driving - Online Traffic School - Defensive Driving Course
If you have knowledge, let others light their candles in it.
saadatshah is offline
Reply With Quote
View Public Profile Visit saadatshah's homepage!
 
Old 08-25-2006, 06:00 PM Re: Externally Linking JS
kIDJOE's Avatar
Extreme Talker

Posts: 180
Location: Hollywood, CA
Hide from old browser.. but hey who cares about super old browsers that wont call a JS?
kIDJOE is offline
Reply With Quote
View Public Profile Visit kIDJOE's homepage!
 
Old 08-28-2006, 11:57 PM Re: Externally Linking JS
funkdaddu's Avatar
Web Design Snob

Posts: 636
Quote:
Originally Posted by JA1 View Post
remember the trailing </script> otherwise your browser will stuff up!

<script type="text/javscript" src="yourscript.js"/></script>


J.

I used a self-closing tag (hence the / before the last > which is technically correct. Just like you can use <br/> Which browser will hang on that?

EDIT: OK, it is not valid HTML 4, but it is valid in XHTML. So I guess it depends which Doctype you're using

Last edited by funkdaddu : 08-29-2006 at 12:08 AM. Reason: Found Answer
funkdaddu is offline
Reply With Quote
View Public Profile Visit funkdaddu's homepage!
 
Old 09-12-2006, 11:32 AM Re: Externally Linking JS
3rdShiftStudios's Avatar
Ultra Talker

Posts: 252
Name: Jaison Tortorea
Location: cincinnati, oh
ok, i'm really new at this kinda of thing, can someone please give me a complete break down of where you put what and how to set up the remote file also?

my site in question is this: www.jaap-orr.com/link/index.html

I'd like the navigation along the top to be remote sourced and I just can't seem to find a point -by -point "how to" on it. I'm sorry to sound like a total noob but really i just don't get how to set up the references or the external file... thanks!
3rdShiftStudios is offline
Reply With Quote
View Public Profile Visit 3rdShiftStudios's homepage!
 
Old 09-12-2006, 03:34 PM Re: Externally Linking JS
Extreme Talker

Posts: 177
If you're attaching an external JavaScript file, put the:

<script language="javascript" src="abc.js" type="text/javascript"></script>

between the <head> and </head> tags.
__________________
Bulbous Bouffant
CouponGuy is offline
Reply With Quote
View Public Profile
 
Old 09-12-2006, 09:19 PM Re: Externally Linking JS
3rdShiftStudios's Avatar
Ultra Talker

Posts: 252
Name: Jaison Tortorea
Location: cincinnati, oh
Quote:
Originally Posted by CouponGuy View Post
If you're attaching an external JavaScript file, put the:

<script language="javascript" src="abc.js" type="text/javascript"></script>

between the <head> and </head> tags.
and denn? like i said, really need a whole discertation on how to set this up....

like what do i do for the buttons at the top? do i put their coding in the index page or on the js page?
3rdShiftStudios is offline
Reply With Quote
View Public Profile Visit 3rdShiftStudios's homepage!
 
Old 09-12-2006, 09:26 PM Re: Externally Linking JS
Extreme Talker

Posts: 177
And then you can make the function calls in your buttons just like you are now. You would keep the buttons the same as they are now.
__________________
Bulbous Bouffant
CouponGuy is offline
Reply With Quote
View Public Profile
 
Old 09-12-2006, 09:43 PM Re: Externally Linking JS
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
Wireless Audio
Posts: 2,320
Name: Keith Marshall
Location: West Hartford, CT
Quote:
Originally Posted by funkdaddu View Post
I used a self-closing tag (hence the / before the last > which is technically correct. Just like you can use <br/> Which browser will hang on that?

EDIT: OK, it is not valid HTML 4, but it is valid in XHTML. So I guess it depends which Doctype you're using
I have been curious to this type of usage in xhtml 1.0. Is it OK to use a self closing tag (i.e. "/>") on tags that are commonly used with opening/ending tags?

Example - Are these valid?

<textarea />
<script />
<a name="section1" />


(what about my username, is that legal? - lol)
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 09-12-2006, 11:18 PM Re: Externally Linking JS
funkdaddu's Avatar
Web Design Snob

Posts: 636
No, those don't validate as they are... they are missing attributes and not enclosed in a paragraph, form, etc... Use this and play around...
This does validate:
HTML Code:
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html>

	<head>
		<title>Untitled Page</title>
		<script type="text/javascript" src="test.js"/>
	</head>

	<body>
	<p><textarea rows="20" cols="20"/></p>
	<script type="text/javascript" src="test.js"/>
	<p><a name="section1" /></p>
	</body>

</html>
__________________
Will Work For Talkputation...

Last edited by funkdaddu : 09-12-2006 at 11:21 PM.
funkdaddu is offline
Reply With Quote
View Public Profile Visit funkdaddu's homepage!
 
Old 09-13-2006, 04:19 PM Re: Externally Linking JS
Super Talker

Posts: 110
Name: Jason
In order for Javascript to validate make sure you insert the doc type in the code.
autoecart is offline
Reply With Quote
View Public Profile Visit autoecart's homepage!
 
Reply     « Reply to Externally Linking JS
 

Thread Tools

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

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




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.19913 seconds with 12 queries