Jump to content

Recommended Posts

Done various searches to find out out to get the screen width. Need to do this to set the width and scrollable height of a table. Mostly, people talk about using javascript to set a cookie. Am I on to a loser here? Occurs that the user may not have cookies set. Also, in my implementation of apache/google chrome get an access error when trying to do (code example from the web):

 

<head>
<?
if(isset($_COOKIE['screenresolution'])) {
 //cookie found!
 $screenres = $_COOKIE['screenresolution'];
} else {
 //cookie is not found, so set it with JavaScript
?>
 <script language="javascript">
 <!--
 writeCookie();
 function writeCookie() {
  var enddate = new Date("December 31, 2060");
  document.cookie = "screenresolution="+ screen.width +"x"+ screen.height + ";expires=" + enddate.toGMTString();
  window.location.replace("<?= $_SERVER['PHP_SELF'] .'?'.$_SERVER['QUERY_STRING']  ?>");
 }
 //-->
 </script>
<?
}
?>
</head>
 
 
Access forbidden!

You don't have permission to access the requested object. It is either read-protected or not readable by the server.

If you think this is a server error, please contact the webmaster.

Error 403
 
Link to comment
https://forums.phpfreaks.com/topic/280457-getting-the-screen-width/
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.