Can anybody tell me how to detect a users screen resolution in php?
| SitePoint Sponsor |





Can anybody tell me how to detect a users screen resolution in php?





You can't use javascript?Originally Posted by Archbob





Something like this?
http://www.pageresource.com/jscript/jscreen.htm
You could maybe use XMLHttpRequest/AJAX to do it "quietly".





Well, I want to do it in php so I can render two different sites for those above a certain resolution and those below a certain resolution.
The window href thing doesn't quite work.





Did you read that whole page?Originally Posted by Archbob





why wouldn't this work?
You could change that to something like:Code:<SCRIPT language="JavaScript"> <!-- if ((screen.width>=1024) && (screen.height>=768)) { window.location="highres.html"; } else { window.location="lowres.html"; } //--> </SCRIPT>
window.location = "scriptname.php?res=low"
or
window.location = "scriptname.php?res=high"
Couldn't you?
Edit:
You could put that script inside a PHP if statement so it only checks the first time.
PHP is server-side it can not do client-side stuff.





Thanks, my lack of creativity disgusts me.Originally Posted by coo_t2

i wouldnt recommend creating differnt pages for different screen dimensions.Well, I want to do it in php so I can render two different sites for those above a certain resolution and those below a certain resolution.
just make your design 'scalable'





Thats not always possible, especially since advertisement only come in a few sizes.
Bookmarks