473,836 Members | 2,292 Online
Bytes | Software Development & Data Engineering Community
+ 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 50053
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)

iD8DBQFEMh5n3jc Q2mg3Pc8RAk+VAJ 4nMhHaxV/RJzzhiZqflvXAPW upswCfTdEp
g9bI5XyjhKopD3h 4JNPPDgI=
=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="JavaS cript>
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.c om wrote:
You can do this by JavaScript not PHP (or both of them together for
some reason):

<script language="JavaS cript>
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.locati on.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.c om wrote:
You can do this by JavaScript not PHP (or both of them together for
some reason):

<script language="JavaS cript>
A little addition:

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

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.colorDep th;

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.goo glegroups.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

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

Similar topics

2
12793
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 the window or frame). I'm trying to use Javascript to do so. I can sort of get an example working in a Mozilla browser: > <!-- This works on Mozilla only (and maybe netscape) --> > <script language="Javascript"> > document.write( "<applet...
5
5438
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 small. For some reason it treats the table layout as though it is a fixed width, giving a nasty horizontal scroll bar - but if you click refresh it behaves correctly, wrapping content within the window. The site works well with Netscape, Mozilla...
3
9672
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 size was changed. How can I make the scrolling content "stick" the position with respect to the scrollowing box? Your advise is appreciated. Spencer
5
14256
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
2052
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 / width? TIA
3
12213
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, but i need this information on the server side. thanks. -- Just another lost developer.....
31
3556
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I modify the current browser window? ----------------------------------------------------------------------- In a default security environment you are very limited in how much you can modify the current browser window. You can use ` window.resizeTo ` or ` window.moveTo ` to resize or move a window respectively, but that is it. Normally you can...
0
1972
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 the content, my background div's and their images start to decrease horizontally. I think it has something to do with my #main div as well as my #wrap div's. They are the ones decreasing horizontally and eliminating everything in their path...
0
1116
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 here's an example of the style: http://www.jedroot.com/photogr/ga1/aroch-fashion.php?story=http://www.jedroot.com/photogr/ga1/fashion/french/french-0710-woosha.html I'd really love it if the frame could change width when I changed the width of my...
0
9810
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10821
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10527
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10573
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10241
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7773
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6973
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
4001
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3102
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.