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

03-15-2006, 09: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?


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>


Please use code tags when posting code

03-15-2006, 10:58 AM

javascript has width and height methods

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

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

03-15-2006, 04:16 PM
Also try Cameron's (the man in blue) script on how to change design based on resolution.
I just met him at SXSW, great guy and co-author of Sitepoint's latest DOM scripting book.