Need hlp with validating javascript

They have: 6 posts

Joined: Mar 2005

Okey.
My website was all and nice w3c valid....until....
I made a javascript script (lol) to detect the user's resolution, and adjust the main div (content div)'s width:percenatge accordingly.

I have been working on this for hours, in different ways trying to get w3c to validate it, but it just won't.

Mabye someone here can explain what the hell is wrong.

Website (layout dev stage)
http://ists.buildtolearn.net/ists3/

w3c validation page:
http://validator.w3.org/check?uri=http%3A%2F%2Fists.buildtolearn.net%2Fists3%2F

code:

<?php
<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">
<head>
<link rel=\"stylesheet\" type=\"text/css\" href=\"ists.css\" />
<title>Internet Security and Tech Support</title>
</head>
<body>


<h3 style=\"position:absolute; margin:0px; left:36%;\">Internet Security and Tech Support</h3>
<div class=\"nav\" style=\"top:0px;\">
<div class=\"cnav\">Main</div>
&nbsp;<a href=\"\">Home</a><br />
&nbsp;<a href=\"\">Virus Watch</a><br />
&nbsp;<a href=\"\">Forum</a><br />
&nbsp;<a href=\"\">Tools</a><br />
&nbsp;<a href=\"\">Glossary</a><br />

</div>

<div class=\"nav\" style=\"top:3px;\">
<div class=\"cnav\">Online</div>
&nbsp;<a href=\"d\">Viruses</a><br />
&nbsp;<a href=\"d\">Parasites</a><br />
&nbsp;<a href=\"d\">Secure your PC</a><br />
&nbsp;<a href=\"d\">Do's and Don'ts</a><br />
</div>

<div class=\"nav\" style=\"top:6px;\">
<div class=\"cnav\">Offline</div>
&nbsp;<a href=\"d\">Software Probs</a><br />
&nbsp;<a href=\"d\">Hardware Probs</a><br />
&nbsp;<a href=\"d\">Maintenence</a><br />
&nbsp;<a href=\"d\">Do's and Dont's</a><br />
</div>

<div class=\"nav\" style=\"top:10px;\">
<div class=\"cnav\">Website</div>
&nbsp;<a href=\"d\">About Us</a><br />
&nbsp;<a href=\"d\">Contact Us</a><br />
&nbsp;<a href=\"d\">Help Us</a><br />
&nbsp;<a href=\"d\">Donate</a><br />
&nbsp;<a href=\"d\">Links</a><br />
</div>


<div class=\"rights\" style=\"top:10px;right:2px;\">
<div class=\"cnav\">Poll</div>
This is just a Test Poll. What is your opinion of the site layout?
</div>

&lt;script language=\"javascript\" type=\"text/javascript\"&gt;
var jswidth = screen.width;
if (jswidth==800) document.write(\"<div class='main' style='width:64%;'>\");
else if (jswidth==1024) document.write(\"<div class='main' style='width:73%;'>\");
else if (jswidth==1152) document.write(\"<div class='main' style='width:76%;'>\");
else if (jswidth==1280) document.write(\"<div class='main' style='width:78%;'>\");
else document.write(\"<div class='main' style='width:64%;'>\");
&lt;/script&gt;

Content Here<br />
<br />
Links here<br />
<br />
<a href=\"\">Here</a><br />
<a href=\"\">sample link1</a><br />
<a href=\"\">link2</a><br />
<a href=\"\">yet another link</a><br />
<br />
I GODDAMN HATE MICROSOFT INTERNET EXPLORER!!
</div>

<br /><br />
<pre class=\"bottom\"><a href=\"http://jigsaw.w3.org/css-validator/validator?uri=http://ists.buildtolearn.net/ists3/\" target=\"istsw3ccheckxhtml\">
<img src=\"http://www.w3.org/Icons/valid-xhtml10\" class=\"imgi\" alt=\"Valid XHTML 1.0!\" height=\"31\" width=\"88\" border=\"0\" /></a>
<a href=\"http://jigsaw.w3.org/css-validator/validator?uri=http://ists.buildtolearn.net/ists3/\" target=\"istsw3ccheckcss\">
<img width=\"88\" height=\"31\" class=\"imgi\" src=\"http://jigsaw.w3.org/css-validator/images/vcss\" alt=\"Valid CSS!\" /></a>
&copy; Copyright 2005 Starcraftmazter
</pre>

</body>
</html>
?>

Like I said, it only started happening after the javascript addon.

Any suggestions on how to get w3c to validate this??

BTW. Yes, I know the stuff on the bottom overlaps the other stuff at higher resolutinos. I couldn't care less right now.

dk01's picture

He has: 516 posts

Joined: Mar 2002

In XHTML when you use javascript since it does not follow the normal document flow you must use something called CDATA to tell the xml parser that you are using something other than html.

See this post.

Also you haven't validated you xhtml. You have both validator links going to the css validator. Here is the xhtml validator link:

http://validator.w3.org/check?uri=http%3A%2F%2Fists.buildtolearn.net%2Fists3%2F&charset=%28detect+automatically%29&doctype=%28detect+automatically%29&ss=1&verbose=1

Good luck.

-dk

They have: 6 posts

Joined: Mar 2005

Aight.

Well I decided to just use an external .js file for that, since those tags unfortunately didn't work for firefox Sad

But it's all w3c valid now, thanks for pointing out that thread - it helped Laughing out loud

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.