referencing to external JS
i went and ran my XHTML 1.0 Transitional code through the W3C validator, it was mostly good, but i "failed" because i have internal JS that has characters not allowed...how can i have JS file and then link to it, like an external stylesheet? thanks
fspigroup posted this at 21:07 — 25th April 2003.
They have: 5 posts
Joined: Feb 2003
the best way to link to a javascript file is:
<script TYPE="text/javascript" SRC="http://www.javalocation.com/filename.js"></script>
<script LANGUAGE="VBScript">
It should be as sime as that.
DB
http://www.fspigroup.com
http://www.fsprom.com
http://www.fsprecords.com
http://www.fspsiteweaver.co.uk
kb posted this at 02:27 — 26th April 2003.
He has: 1,380 posts
Joined: Feb 2002
i don't have to close the "<script LANGUAGE="thelanguageofthescript">"?
thanks
kb posted this at 02:55 — 26th April 2003.
He has: 1,380 posts
Joined: Feb 2002
actually i did a little research on w3c.org about the XHTML Strict documentation...and i found the reason was acutally i didn't explain it was "unescaped javascript content"...so heres what i got, but the JS doesnt work:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
blah, blah
<script type="text/javascript">
<![CDATA[
rest of the JS
]]>
</script>
if i take the CData stuff out...it works...but with it, it doesnt...i copied and pasted straight from W3C http://www.w3.org/TR/xhtml1/#h-4.8
anybody got a clue? thanks
dk01 posted this at 07:57 — 26th April 2003.
He has: 516 posts
Joined: Mar 2002
Can we see the page because I know you need the cdata things for it to work. If not then the xml preprocessor will think that your javascript (eg. if(myvar > 1) ) is actually html and make it into: if(myvar > 1) )
If you show the code we may be able to see whats wrong.
-dk
kb posted this at 15:51 — 26th April 2003.
He has: 1,380 posts
Joined: Feb 2002
yea, thats what i thought...anyways, its a long script...so i'll post a link
this is a test page: (and its in a file instead of being in the page, cuz i really don't want to show the page itself right now)
http://westernciv.sarvihosting.com/header.js
dk01 posted this at 21:32 — 26th April 2003.
He has: 516 posts
Joined: Mar 2002
Ok that code was written on a unix machine or something and I have to say that without the full page we won't be able to help. The javascript is not the problem most likely, instead the xhtml is probably the culprit.
-dk
kb posted this at 17:50 — 27th April 2003.
He has: 1,380 posts
Joined: Feb 2002
argh...ok, thanks...i'll try to see what i can do, if i cant figure it out, i'll start a new thread
Busy posted this at 23:04 — 27th April 2003.
He has: 6,151 posts
Joined: May 2001
if your using server side as well (PHP, ASP ...) don't use <?xml version="1.0" encoding="UTF-8"?> (don't need xml version and can put the encoding in meta tag) or the cdata comments as it can mess things up.
The is meant to be the new comment system for xml but IMHO wasn't thought out properly as it messes with serverside stuff. comments inside your script tags are for the older browsers that don't support it, you can easily leave them out these days as 99% of browsers support it, even if they don't they wont be able to display the xhtml anyways.
kb posted this at 00:11 — 29th April 2003.
He has: 1,380 posts
Joined: Feb 2002
i saw that, and i decided to go ahead and link to an external document, as i do with php as well...thanks, i got it working now
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.