|
|
|
|
![]() ![]() |
Sep 1 2004, 11:14 AM
Post
#1
|
|
|
Administrator Group: Admin Posts: 458 Joined: 26-August 04 Member No.: 1 |
Is it possible to get the screen resolution of the users moniter using only javascript. No other external stuff, just pure javascript. I guess most of the people using JAVA for this. I also got some scripts regarding this which used SCREEN.WIDTH function or something, but they did not seem to work out. Any possible solutions.
BTW, is it possible to get the resolution using PHP ( I guess it is not ) ... |
|
|
|
| Cloak |
Sep 1 2004, 03:18 PM
Post
#2
|
|
Guests |
It is possible with JavaScript, because it is client-side - but not with PHP, as it is server-side.
|
|
|
|
Sep 1 2004, 11:39 PM
Post
#3
|
|
|
BUG.SWAT.PATROL Group: Members Posts: 622 Joined: 1-September 04 From: Auckland, New Zealand Member No.: 27 |
QUOTE(OpaQue @ Sep 2 2004, 12:14 AM) Is it possible to get the screen resolution of the users moniter using only javascript. No other external stuff, just pure javascript. I guess most of the people using JAVA for this. I also got some scripts regarding this which used SCREEN.WIDTH function or something, but they did not seem to work out. Any possible solutions. BTW, is it possible to get the resolution using PHP ( I guess it is not ) ... This is quite easy, but when you say screen.width doesn't seem to work makes me wonder what the problem could be? screen.width and screen.height work with NS 4+ and IE 5+ web browsers. We can output on our site what their resolution our viewers are running at, dependant on their browser. to do this we do: CODE <script language="javascript"> <!-- document.write('<p> +screen.width+ ' x ' +screen.height+ '</p>'); //--> </script> You can't use PHP to grab client information because it is a server-side script and has no involvement with the client. If you're wondering how you get browser agent names and such, that is because this is sent within the HTTP Headers upon request. Usually you would use a mix of JavaScript and PHP to help you with creating optimised sites for your viewers. Cheers, MC |
|
|
|
Sep 6 2004, 05:54 AM
Post
#4
|
|
|
Member [ Level 1 ] Group: [HOSTED] Posts: 39 Joined: 6-September 04 From: England Member No.: 294 |
ok thanks useful
|
|
|
|
Sep 10 2004, 02:21 PM
Post
#5
|
|
|
Newbie [ Level 1 ] Group: Members Posts: 3 Joined: 9-September 04 From: Norway Member No.: 426 |
QUOTE(OpaQue @ Sep 1 2004, 01:14 PM) BTW, is it possible to get the resolution using PHP ( I guess it is not ) ... With the combination of server side scripting and client side scripting, it is possible: CODE <script language="javascript"> <!-- document.write('<a href=getscrsize.php?scrw='+screen.width+'&scrh='+screen.height+'>'); //--> </script> Clich here to tell what me your screen size is!</a> Then, in the PHP script, you can get the screen size by using these two variables: CODE $_GET['scrw']
$_GET['scrh'] |
|
|
|
Sep 13 2004, 02:02 AM
Post
#6
|
|
|
Member [ Level 1 ] Group: [HOSTED] Posts: 31 Joined: 9-September 04 Member No.: 402 |
Some browsers (I think ns4 and below) use 'screen.availWidth' to get width and screen.availHeight to get height.
Try that if screen.width and screen.height does not work. |
|
|
|
Jan 29 2008, 07:46 AM
Post
#7
|
|
|
Newbie [ Level 1 ] Group: Members Posts: 0 Joined: 1-November 07 Member No.: 25,869 |
Getting Screen Resolution using Javascript.
Getting Screen Resolution using Javascript. <A HREF="javascript:alert('Your resolution is '+screen.Width+'x'+screen.Height);"> Click for your screen resolution</A> -Sathish kumar |
|
|
|
May 8 2008, 03:36 AM
Post
#8
|
|
|
Member [ Level 1 ] Group: [HOSTED] Posts: 40 Joined: 17-April 08 Member No.: 29,853 |
I am curious... Is there a way to get the height and width of the viewing area as opposed to the entire screen? Let's say for example that I have a website that will direct users to different HTML pages depending on their resolution. But it still will not display properly if a user uses only half a screen for their browser.
I would just like to get the width from the inside of the border on the left to the scroll bars on the right and the height from the bottom of the toolbars to the top of the status bar. Can this be done? - Jared |
|
|
|
May 8 2008, 08:45 AM
Post
#9
|
|
|
Premium Member Group: Members Posts: 422 Joined: 29-September 06 Member No.: 16,228 |
No, there's no way to know if a browser window is maximised or anything like that.
|
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 5th July 2008 - 11:56 PM |