html validator
Hi,
im just looking for advice on validating one of my pages. i just need to know why it picks up things like ";" etc in javascript, if you go to http://validator.w3.org/check?uri=http%3A%2F%2Fwww.swiftmediauk.co.uk%2Fwebsite-design.php&charset=%28detect+automatically%29&doctype=Inline
could someone please tell me why it picks up things like that, eg. ; , < , >
Kind Regards,
Andy MacDonald
timjpriebe posted this at 19:48 — 23rd May 2006.
He has: 2,667 posts
Joined: Dec 2004
You might try, right before you open and close the Javascript, adding HTML comment tags. Something like this...
<script type="text/JavaScript">
<!--
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
-->
</script>
I'm not 100% sure that will cause it to validate, but you might try it.
Tim
http://www.tandswebdesign.com
WebMaster94 posted this at 00:01 — 24th May 2006.
He has: 37 posts
Joined: May 2006
That should work. I've been having the same problem, so I'll try it!
swiftmed posted this at 06:27 — 24th May 2006.
He has: 59 posts
Joined: Mar 2006
hi,
thanks for your reply guys, i did try that but it didnt work for me. I have been told elsewhere that xhtml doesnt like javacode and i have to rap it in {cddata} or something. going to give that a try in a bit. thanks again.
Kind Regards,
Andy MacDonald
Busy posted this at 11:04 — 24th May 2006.
He has: 6,151 posts
Joined: May 2001
These days you don't need the comments, just remove them
of if you want to use the comments, use the
swiftmed posted this at 11:23 — 24th May 2006.
He has: 59 posts
Joined: Mar 2006
Didnt realise that busy, i use a program called internet business promoter and it always flags up about including them.
JeevesBond posted this at 12:07 — 24th May 2006.
He has: 3,956 posts
Joined: Jun 2002
In fact you should definitely not use comments, they will cause your Javascript code to actually be ignored by future browsers. That's when XHTML is served with as application/xhtml+xml instead of text/html
And don't forget that
a Padded Cell our articles site!
swiftmed posted this at 13:07 — 24th May 2006.
He has: 59 posts
Joined: Mar 2006
Ideal, also thanks for the demonstration as well mate. thats really helped. i appreciate it.
CptAwesome posted this at 14:53 — 24th May 2006.
He has: 370 posts
Joined: Dec 2004
And all this is why you should try and use external javascript
swiftmed posted this at 16:13 — 24th May 2006.
He has: 59 posts
Joined: Mar 2006
how do i use external javascript mate? or do you know anywhere that can show me please?
CptAwesome posted this at 20:12 — 24th May 2006.
He has: 370 posts
Joined: Dec 2004
<script type="etc" language="etc" src="/path/to/file.js"></script>
and anything you would have put inside the <script> tags you put in file.js
JeevesBond posted this at 01:42 — 27th May 2006.
He has: 3,956 posts
Joined: Jun 2002
Yep, Mr Awesome has a point. It's easier to keep everything as seperate as possible (e.g. instead of using use the AddEventListener function in a seperate Javascript file). JavaScript in one file, HTML in a different file and CSS in another one.
Then you'll have no confusion when you come back to your code in six months time needing to make a change.
a Padded Cell our articles site!
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.