tags:

views:

31

answers:

2

That is, how much browser space they have, not resolution or size of window? I'd rather not use javascript, but I'm pretty sure that it's the only option for me since PHP is all server side.

+1  A: 

You'll need some sort of javascript on the client-side set up to pass back the height and width to the server through querystring parameters, cookies, hiddenInput, etc., so that on your next page load you'll have those parameters on the server side.

JQuery is one of the libraries that will help give you a cross-browser mechanism for pulling out these parameters--so after including the necessary jquery.js file in your header you would render something like this in a default.php to pass the params into the querystring for LandingPage:

<script>    
  window.location.href = "LandingPage.php?height=" + $(window).height() + "&width=" + $(window).width(); 
</script>

This would redirect you, for example, to LandingPage.php?height=1240&width=300 and then you could pull out the height=1240 and width=300 parameters in PHP fairly easily.

Despite being called $(window).height()/width() you will actually be getting the height and width of the browser viewport.

It might be annoying for clients to have to go through a redirect like that but there is no way to know what the client's height/width are on the first HTTP request you receive on your server.

nvuono
+1  A: 

Detect Browser Window Size from JavaScript
http://tipsntricksbd.blogspot.com/2008/11/detect-browser-window-size-from.html

Assuming that, by screen real estate, you mean the amount of area they have available in their open browser window to browse with.

Robert Harvey