W3C home > Mailing lists > Public > www-validator@w3.org > April 2005

Re: [VE][108] Error Message Feedback

From: Terrence Redfield <tredfiel@rochester.rr.com>
Date: Wed, 20 Apr 2005 16:49:43 -0400
Message-ID: <01b201c545ea$7aec56a0$6500a8c0@rochester.rr.com>
To: <www-validator@w3.org>
Thank you to Jukka "Yucca" Korpela and Philip Taylor for the interest and responses.

Actually, I spent about 5 minutes "Google"ing and 5 minutes figuring out my own problem.  If W3C's validator has done anything for me, it's that it has forced me to become a better programmer.  (Believe me, there's plenty of room for improvement!)

Here's the problem, simply stated (if that's possible):

The page in question floats to center (left to right) depending on the available window width.  The page holds a DIV that is positioned as a function of the available width.  Here is the old code (the one that didn't validate with W3 but worked fine in IE anyway):

<html>
<head>
 ...
</head>
<body onResize="document.location.href=document.location">
 ...
 ...
 <div id="oTransContainer" etc, etc...>
 ...
 ...
 <script language="JavaScript" type="text/javascript">
 oTransContainer.style.top=243
 if(document.body.clientWidth>=780) {
  oTransContainer.style.left=(document.body.clientWidth - 500) / 2 + 30
 } else {
  oTransContainer.style.left=170
 }
 </script>
</body>
</html>
==========================================================

Here is the revised code which both works and validates:

<html>
<head>
 ...
 <script language="JavaScript" type="text/javascript">
 function adjust() {
  oTransContainer.style.top=243
  if(document.body.clientWidth>=780) {
   oTransContainer.style.left=(document.body.clientWidth - 500) / 2 + 30
  } else {
   oTransContainer.style.left=170
  }
 }
 window.onresize=adjust;
 </script>
</head>
<body>
 ...
 ...
 <div id="oTransContainer" etc, etc...>
 ...
 ...
 <script language="JavaScript" type="text/javascript">
  window.onload=adjust;
 </script>
</body>
</html>
==========================================================

So instead of reloading to force a run through the bit of javaScript at the end of the body, the new code calls a function instead.  Of course, doing it this way is much faster (immediate) because the page visitor doesn't have to wait for a reload.

New code in use at:

http://hiltonbigm.com/gallery_show_pics.asp?id=1

Again, thanks for the help.

 - Terry

Terrence Redfield
Redfield Associates
Rochester NY USA

PS - Don't expect this to work at all in NetScape (yet)
Received on Wednesday, 20 April 2005 20:49:08 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 25 April 2012 12:14:18 GMT