hwo to get browser window size?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Baron Samedi

    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.

  • Ian Collins

    #2
    Re: hwo to get browser window size?

    Baron Samedi wrote:[color=blue]
    > 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?
    >[/color]
    JavaScript. You can't do this server side.

    --
    Ian Collins.

    Comment

    • Iván Sánchez Ortega

      #3
      Re: hwo to get browser window size?

      -----BEGIN PGP SIGNED MESSAGE-----
      Hash: SHA1

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

      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-----

      Comment

      • webramz@gmail.com

        #4
        Re: hwo to get browser window size?

        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

        Comment

        • Scott

          #5
          Re: hwo to get browser window size?

          On Tue, 2006-04-04 at 01:28 -0700, webramz@gmail.c om wrote:[color=blue]
          > 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
          >[/color]

          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.

          Comment

          • Baron Samedi

            #6
            Re: hwo to get browser window size?

            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)

            Comment

            • Erwin Moller

              #7
              Re: hwo to get browser window size?

              webramz@gmail.c om wrote:
              [color=blue]
              > You can do this by JavaScript not PHP (or both of them together for
              > some reason):
              >
              > <script language="JavaS cript>[/color]

              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. :-)

              [color=blue]
              > var w = screen.width;
              > var h = screen.height;[/color]

              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
              [color=blue]
              >
              > alert('You are using ' + w + 'x' + h + ' resolution...!' );
              >
              > </script>
              >
              > Behzad Nategh[/color]

              Comment

              • ryanf

                #8
                Re: hwo to get browser window size?

                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:[color=blue]
                > 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.[/color]

                Comment

                • Baron Samedi

                  #9
                  Re: hwo to get browser window size?

                  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)

                  Comment

                  • Wog George

                    #10
                    Re: hwo to get browser window size?


                    "Baron Samedi" <Papa.Legba.666 @gmail.com> wrote in message
                    news:1144200994 .642929.192920@ z34g2000cwc.goo glegroups.com.. .[color=blue]
                    > 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)
                    >[/color]

                    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


                    Comment

                    • julian_m

                      #11
                      Re: hwo to get browser window size?


                      webramz@gmail.c om wrote:[color=blue]
                      > 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>
                      >[/color]

                      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

                      Comment

                      Working...