HighDots Forums  

Change attribute? (Javascript)

Macromedia Dreamweaver Macromedia Dreamweaver Discussions (macromedia.dreamweaver)


Discuss Change attribute? (Javascript) in the Macromedia Dreamweaver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
mzanime.com
 
Posts: n/a

Default Change attribute? (Javascript) - 07-16-2004 , 02:44 PM






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.




Reply With Quote
  #2  
Old   
Gary White
 
Posts: n/a

Default Re: Change attribute? (Javascript) - 07-16-2004 , 05:32 PM






"mzanime.com" <webforumsuser (AT) macromedia (DOT) com> wrote

Quote:
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.

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.



Quote:
I tried writing this little bit of JS, and it works but both Dreamweaver
and
the W3C says that its bad coding. :-)
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:


Quote:
script language="JavaScript" type="text/javascript"
//<![CDATA[

Quote:
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'>");}
//]]>

Quote:
/script

Gary




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.