How do I get the screen resolution using PHP?
Screen resolution
Started by
Guest_NeedHelp_*
, May 10 2007 12:47 PM
6 replies to this topic
#1
Guest_NeedHelp_*
Posted 10 May 2007 - 12:47 PM
Guest_NeedHelp_*
|
|
|
#2
Posted 10 May 2007 - 01:04 PM
The screen resolution of the server or the client?
To get the resolution of the server you would have to use the exec() function and execute the unix/dos command to get the resolution (are there any?)
But you probably mean the client, which you would use JavaScript
You can write the resolution to a cookie and use the php cookie functions to grab the resolution from the cookie file.
To get the resolution of the server you would have to use the exec() function and execute the unix/dos command to get the resolution (are there any?)
But you probably mean the client, which you would use JavaScript
<script type="text/javascript"> document.write(window.screen.width + ' x ' + window.screen.height); </script>
You can write the resolution to a cookie and use the php cookie functions to grab the resolution from the cookie file.
#3
Guest_Jordan_*
Posted 11 May 2007 - 05:37 AM
Guest_Jordan_*
To get the client records you will need to use Javascript and there is no way that PHP can receive this value since it is server side.
#4
Guest_NeedHelp_*
Posted 11 May 2007 - 10:17 AM
Guest_NeedHelp_*
Hmm, I really just need to make an if statement and if their resolution is lower than a certain value display an error message. Do I need to do a cookie and everything for that?
#5
Posted 11 May 2007 - 07:29 PM
How would you compare the value?
Im pretty sure if you want to use php to display the error message you have to use cookies, unless there is another way to store the width/height. You could always of course display the error in JavaScript. Im no JS expert but maybe something like this
if(<script type="text/javascript"> document.write(window.screen.width + ' x ' + window.screen.height); </script> < 1024) echo "Error";
Im pretty sure if you want to use php to display the error message you have to use cookies, unless there is another way to store the width/height. You could always of course display the error in JavaScript. Im no JS expert but maybe something like this
<script type="text/javascript">
if(window.screen.width < 1024)
allert("Your screen is too small");
</script>
#6
Guest_Jordan_*
Posted 12 May 2007 - 11:03 AM
Guest_Jordan_*
What Sidewinder suggested would work well. You could also create a dynamic page using JavaScript or simply forward the user to an error page (like res.html) with the same logic above.
#7
Guest_NeedHelp_*
Posted 14 May 2007 - 10:54 AM
Guest_NeedHelp_*
That works. I'll figure out something. Thank you.


Sign In
Create Account

Back to top









