Originally Posted by
brennydoogles
Hello, I am trying to figure out how to determine a User's screen width in Javascript, and have it available in PHP as a variable. I have done a bit of research, and I think that for my purposes this could be best accomplished by setting a cookie, but I have almost no knowledge of Javascript, and my PHP is weak. To make things slightly more complicated, I plan on putting this code in my head.php file, which is included in all of the pages on my site, so if setting a cookie requires that the page be refreshed, we will need to figure out how to do that to the correct page. Any help would be greatly appreciated!
Such calculations should be done on the client, not server.
PHP Code:
screen.height;
screen.width;
Would be the ECMAScript for it, and you could send this in a form, or use it with Ajax.
Bookmarks