Outline ·
[ Standard ] ·
Linear+
PHP detect browser window size, $_Get['width'] ??
|
TSCodeBasic
|
Apr 30 2009, 11:22 AM, updated 17y ago
|
Getting Started

|
hi..i wan to ask how to use PHP to check the browser window size ? if let say, my code:
<? $myWidth = '<script> document.write(window.innerWidth); </script>';
echo $myWidth; if ($myWidth < 1008) { //when i resize the browser window to 1024x768px, the echo $myWidth is 1008 $setWidth = 550; echo '<div id="Panorama" style="width:'.$setWidth.'px; height:130px;overflow:hidden; background-color: transparent; margin-top:5; padding: 20px; margin-left: 0px;">'; } else { //when i resize the browser window to 1280x800px, the echo $myWidth is 1264 $setWidth = 750; echo '<div id="Panorama" style="width:'.$setWidth.'px; height:130px;overflow:hidden; background-color: transparent; margin-top:5; padding: 20px; margin-left: 0px;">'; }?>
My problem is : No matter how i resize the browser window size, it always go to if ($myWidth < 1008){}...i cant get the $setWidth correctly, anything wrong in my code?
This post has been edited by CodeBasic: Apr 30 2009, 11:24 AM
|
|
|
|
|
|
TSCodeBasic
|
Apr 30 2009, 04:45 PM
|
Getting Started

|
i still not understand how to write
|
|
|
|
|
|
TSCodeBasic
|
May 4 2009, 11:10 AM
|
Getting Started

|
But i still face with the problem on doing that cos i just use javascript function to handle scroll left and right...and i used php function to display my image... public static function DisplayForum($o) { $forums = self::GetWholeForums(); foreach ($forums as $f) { $base = $o->forum->id == $f->id ? 'fheader' : 'option'; echo '<td width="25px;" align="center">' .'<a href="viewforum.php?fid='.$f->id.'">' .'<img src="/img/forum/'.$base.$f->id.'.gif">' .'</a>' .'</td>'; } } so what can i do now? Another question is: http://i268.photobucket.com/albums/jj20/im...lee1983/ask.jpghttp://i268.photobucket.com/albums/jj20/im...ee1983/ask2.jpghttp://i268.photobucket.com/albums/jj20/im...ee1983/ask3.jpghttp://i268.photobucket.com/albums/jj20/im...ee1983/ask4.jpgHow can make the image displayed in center or scroll left a bit so that can see the image display? Bcos i don wan ppl to scroll right again after they click the image This post has been edited by CodeBasic: May 4 2009, 11:11 AM
|
|
|
|
|