Change attribute? (Javascript)

message from mzanime.com on 16 Jul 2004
I'm creating a template specifically for large data tables so the header and
footer are just two small included tables containing text. But I want the
header and footer to be aligned "default" for users with 600x800 resolution and
aligned to the "center" for users with 1024x768 and higher.

I tried writing this little bit of JS, and it works but both Dreamweaver and
the W3C says that its bad coding. :-)

<script language="JavaScript" type="text/javascript">
if (window.screen.width>=1024) { document.write("<table border='0'
cellpadding='0' cellspacing='0' align='center' width='750'>");
} else if (window.screen.width>=800) { document.write("<table border='0'
cellpadding='0' cellspacing='0' width='750'>");}
</script>
<noscript><table border='0' cellpadding='0' cellspacing='0' align="center"
width="750"></noscript>

All I really need to do is alter the alignment of both included header/footer
tables. If anyone else has a better (and preferrably shorter) JS solution to
doing this based upon user resolution I'd be greatful.
 
Gary White replied to mzanime.com on 16 Jul 2004
What, exactly, do you think that screen resolution has to do with anything?
I use machines with 1024x768 and 1280x1024, but I rarely have a browser
window wider than 800.

It is bad coding. Relying on screen resolution to lay out the page is a
flawed approach and will not give good results in many cases. However, if
all you want is for this bad code to validate, add the two lines below:

//<![CDATA[

//]]>

Gary
 

Archived message: Change attribute? (Javascript) (Macromedia Dreamweaver Web Design)