473,478 Members | 2,028 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

hwo to get browser window size?

I want to collect stats about people viewing my web site.

Actually, I already use Awstats, but it doesn't do what I want, so I
will code it myself.

I want to know what size browser window visitors to my site use
(preferably; failing that, what their monitor resolution is).

I want this info so that I can know what sort of resolution to display
my photographs at.

Any ideas?

Thanks in advance.

Apr 4 '06 #1
10 50028
Baron Samedi wrote:
I want to collect stats about people viewing my web site.

Actually, I already use Awstats, but it doesn't do what I want, so I
will code it myself.

I want to know what size browser window visitors to my site use
(preferably; failing that, what their monitor resolution is).

I want this info so that I can know what sort of resolution to display
my photographs at.

Any ideas?

JavaScript. You can't do this server side.

--
Ian Collins.
Apr 4 '06 #2
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Baron Samedi wrote:
I want to know what size browser window visitors to my site use
(preferably; failing that, what their monitor resolution is).


Give elinks a try, and you'll realize why this is not possible.

- --
- ----------------------------------
Iván Sánchez Ortega -i-punto-sanchez--arroba-mirame-punto-net

El buen tiempo ayuda en el trabajo.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)

iD8DBQFEMh5n3jcQ2mg3Pc8RAk+VAJ4nMhHaxV/RJzzhiZqflvXAPWupswCfTdEp
g9bI5XyjhKopD3h4JNPPDgI=
=Pmhl
-----END PGP SIGNATURE-----
Apr 4 '06 #3
You can do this by JavaScript not PHP (or both of them together for
some reason):

<script language="JavaScript>
var w = screen.width;
var h = screen.height;

alert('You are using ' + w + 'x' + h + ' resolution...!');

</script>

Behzad Nategh

Apr 4 '06 #4
On Tue, 2006-04-04 at 01:28 -0700, we*****@gmail.com wrote:
You can do this by JavaScript not PHP (or both of them together for
some reason):

<script language="JavaScript>
var w = screen.width;
var h = screen.height;

alert('You are using ' + w + 'x' + h + ' resolution...!');

</script>

Behzad Nategh


You could then send that info to PHP by adding:

document.location.href = 'http://www.currentpage.com?w='+w+'&h='+h;

Then use $_GET['w'] and $_GET['h'] for your resolution.

Of course, this method assumes the user has javascript enabled on their
browser.

Apr 4 '06 #5
Thanks, that is perfect.

I am not anal about collecting 100% of visitors stats, those with JS
active will be enough - for my purposes - since I only want to get an
idea of what size I should show my photos at.
Hmm, It means that I have to - partially - load each page twice,
though. But I guess that I can live with that for a month or two.

(partially, because I stick the JS at the very top, immediately after a
check for whether the H & W params are present. That way I don't load
the main body, graphics, menu, etc when getting the esolution)

Apr 4 '06 #6
we*****@gmail.com wrote:
You can do this by JavaScript not PHP (or both of them together for
some reason):

<script language="JavaScript>
A little addition:

<script type="text/javascript">
is better than
<script language="Javascript">

The ancient language-tag is depricated for some time and could be dropped by
browsers anytime. (better safe than sorry. :-)

var w = screen.width;
var h = screen.height;
In case you care about colordepth, screen also holds a colorDepth.
var colorDepth = screen.colorDepth;

8 means 256 colors.
So it contains the base-2 logarithm.

Regards,
Erwin Moller

alert('You are using ' + w + 'x' + h + ' resolution...!');

</script>

Behzad Nategh


Apr 4 '06 #7
You can do this in JS then send the data with ajax so that it does not
require another page load if all you are doing is collecting stats
Baron Samedi wrote:
I want to collect stats about people viewing my web site.

Actually, I already use Awstats, but it doesn't do what I want, so I
will code it myself.

I want to know what size browser window visitors to my site use
(preferably; failing that, what their monitor resolution is).

I want this info so that I can know what sort of resolution to display
my photographs at.

Any ideas?

Thanks in advance.


Apr 4 '06 #8
Look at http://awstats.sourceforge.net/docs/...tml#SCREENSIZE
you idiot. You use AwStats, which has an optional add-in to do this.

(just added this for the benefit of anyone else who might look at this
thread later)

Apr 5 '06 #9

"Baron Samedi" <Pa************@gmail.com> wrote in message
news:11**********************@z34g2000cwc.googlegr oups.com...
Look at http://awstats.sourceforge.net/docs/...tml#SCREENSIZE
you idiot. You use AwStats, which has an optional add-in to do this.

(just added this for the benefit of anyone else who might look at this
thread later)


Does that mean "you idiot" is directed at anyone else who might look at this
thread later??

--
George
"If I was a towel, why would I be wearing this hat and this fake
moustache" - Steven McTowelie - 19 April 2006
Apr 26 '06 #10

we*****@gmail.com wrote:
You can do this by JavaScript not PHP (or both of them together for
some reason):

<script language="JavaScript>
var w = screen.width;
var h = screen.height;

alert('You are using ' + w + 'x' + h + ' resolution...!');

</script>


And then, you can put links to different Css files, each of them
related with a particular resolution
<a href="yoursite.php?res=1024> your resolution</a><a href
="yoursite.php?res=800 --- and so on

I'm asuming that the visual layout of your site is made through css.
I've done it once, and worked like a charm. I don't understand why some
people thik that this shouldn't be done at all ¿?

regards - jm

Apr 26 '06 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
12764
by: Put 030516 in email subj to get thru | last post by:
I've always been bothered about having to statically declare the size of a Java applet window (container?) in the calling HTML. I've always wanted the moral equivalent of width=50% statement (of...
5
5422
by: Stella | last post by:
Hi, I am attempting to create a site which validates as XHTML 1.1. So far I have got it fully validated but I am not happy with the way Internet Explorer displays the site when the window is...
3
9648
by: spencer | last post by:
Hello, I have an index page with an autoscroller writen with CSS. The problem is the scrolling content(text and inages)'s position is correct but will off position when the broswer(IE) window...
5
14212
by: Just D. | last post by:
How can we get the browser window size from C# codebehind? What's the easiest way to do that? Just D.
1
2030
by: Chris | last post by:
Hello, Is there any formula / functions available for finding a client IE window size. I would like to obtain this information and dynamically move controls / elements based on the window height...
3
12194
by: =?Utf-8?B?KioqKiBLaXRlT3JlZ29uICoqKio=?= | last post by:
I am displaying some dynamic data in a content page, how do i figure out the height and width of the browser in asp.net? I know i can write javascript on the client side to get the information,...
31
3446
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I modify the current browser window?...
0
1958
gauchomatt
by: gauchomatt | last post by:
I have a liquid site which expands perfectly when the browser window is larger than the actual content. However, when I decrease the browser window size to a point that it's smaller horizontally than...
0
1108
by: Jon Gordon | last post by:
Hey all, I have a photo website with a horizontal scrolling frame. I was wondering if it's possible to have the frame change size with the browser window. I'd rather not give my website but...
0
6899
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7019
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
6847
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4757
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4463
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
2980
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
2970
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1288
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
166
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.