PDA

View Full Version : 'If' and 'then' statements and screen size.


malhyp
03-15-2006, 10:13 AM
'If' and 'then' statements and screen size.

--------------------------------------------------------------------------------

Hi there, I have a screen size resolution problem.

Is it at all possible for an 'if' statement to be created that will change the pictures viewed depending on the screen size?

Example.

If screen size = 800x600 then view this.

<div align="left">images/Productsa.gif (products.asp)</div>

If screen size = 1024x768 then view this.
<div align="left">images/Productsc.gif (products.asp)</div>

Thanks

Please use code tags when posting code
Mally.

davidj
03-15-2006, 11:58 AM
yes

javascript has width and height methods

here is a function i wrote to position some nav layer buttons depending on screen res

//notes:
ht & wt are hidden fileds (ht = height, wt =width)
when fired the function checks the rez and populates the hidden fields with numerics like 800, 600

function screenres(){

document.getElementById('ht').value = screen.Height;
document.getElementById('wt').value = screen.Width;

}

You can then use these values to decide what to do next

domedia
03-15-2006, 05:16 PM
Also try Cameron's (the man in blue) script on how to change design based on resolution.
http://www.themaninblue.com/writing/perspective/2004/09/21/
I just met him at SXSW, great guy and co-author of Sitepoint's latest DOM scripting book.