I need to find the screen resolution of a users screen who visits my website?
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
You can set window width in cookies using JS in front end and you can get it in PHP:
You can try RESS (RESponsive design + Server side components), see this tutorial:
http://www.lukew.com/ff/entry.asp?1392
This can be done easily using cookies. This method allows the page to check the stored cookie values against the screen height and width (or browser view port height and width values), and if they are different it will reset the cookie and reload the page. The code needs to allow for user preferences. If persistant cookies are turned off, use a session cookie. If that doesn't work you have to go with a default setting.
b. Javascript: redirect to SELF using window.location.reload(). When it reloads, it will skip the step 3.
E.g., I am using some common cookie functions found on the web. Make sure setCookie returns the correct values. I put this code immediately after the head tag. Obviously the function should be in a a source file.
The only way is to use javascript, then get the javascript to post to it to your php(if you really need there res server side). This will however completly fall flat on its face, if they turn javascript off.
Directly with PHP is not possible but...
I write this simple code to save screen resolution on a PHP session to use on a image gallery.