Go Back   Cloud Computing > Support > PHP Forum
 

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 10-11-11, 02:25
BOD Member
 
Join Date: Aug 2011
Posts: 76
Default Php Resolution

Hello, I was just wondering if there is anyway I can get the user resolution using php.

What I am trying to do is have different stylesheets for the same page depending on the user's resolution. All help appreciated.

I tried with javascript but I have to redirect to a different page to do it.
Reply With Quote
  #2 (permalink)  
Old 10-11-11, 07:54
Rozanne's Avatar
BOD Member
 
Join Date: Nov 2010
Posts: 116
Default

PHP does not provide a function to detect the screen resolution for displaying information about the visitor is not provided natively by the HTTP protocol. by Javascript to detect against the resolution through the width and height attributes of the object screen:

Quote:
screen.width
screen.height
Thus the following code, when inserted into an HTML document, displays the display resolution of the visitor:

Quote:
<script language="Javascript">
<! -
document.write ('simply enter your resolution is'. screen.width + 'x' + screen.height)
//-->
</ Script>
Thus, it is possible to pass the parameter to a PHP script via a redirect in Javascript.

Quote:
<?
if (isset ($ _GET ['r']))
{
echo "<script language=\"JavaScript\">
<! -
document.location = \ "$ PHP_SELF? r = 1 & width = \" + screen.width + \ "& height = \" + screen.height;
//-->
</ Script> ";
}
else {

/ / Code to display upon detection of display resolution
if (isset ($ _GET ['width']) & & isset ($ _GET ['height'])) {
/ / Detected Resolution
}
else {
/ / Resolution not detected
}
}

?>
__________________
BODHost.com: | Dedicated Server Hosting | Cloud Server Hosting
Ph. : +1.866-662-0909 | Email : sales@bodhost.com
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump


All times are GMT -6. The time now is 01:19.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
Copyright © 1999-2012, BODHost Ltd. All rights reserved.