Hi,
I'm new to PHP and I'm building my website right now using PHP/mqSQL. It's not a big site, but rather a personal information site with a portfolio etc.
I've read that PHP can't get the user's screen width, but I found a way to do that.
I don't know if it's good coding or not (I'm new :p ), but it works for me...
You need Javascript and GET to get the screen width...
if (isset($HTTP_GET_VARS["width"])) {
$width = $HTTP_GET_VARS["width"] - 60;
if ($width <= 640)
$width = 620;
}
else if (browser_is_ie())
print "<SCRIPT>location.replace(\"".$PHP_SELF."?width=\" + document.body.offsetWidth);</SCRIPT>"; //IE
else if (browser_is_netscape())
echo "<SCRIPT>location.replace(\"".$PHP_SELF."?width=\" + window.innerWidth);</SCRIPT>"; //NS
Can anyone give me feedback on this. It works in IE, NS, Mozilla, Opera on Windows. Not sure about Mac and Linux (probably... not?!.😕 )
Thank you fellows.