Finding browser screen width

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

    #1

    Finding browser screen width

    What is best way to find browser screen width using javascript that is
    compatible with all types of browsers.
  • kaeli

    #2
    Re: Finding browser screen width

    In article <76d3dc08.04110 81053.73021b13@ posting.google. com>,
    madhumohang@hot mail.com enlightened us with...[color=blue]
    > What is best way to find browser screen width using javascript that is
    > compatible with all types of browsers.
    >[/color]

    There is no one way that works with all browsers. You have to putz around
    with the different methods. It's in the archives here - this question gets
    posed rather frequently. Check google groups.

    Why would you need it, anyway?
    Good coding would have content fit readably no matter the width. The only
    reason you might want it is to check stats or something. If you're trying to
    resize content and whatnot, that's making a mountain out of a molehill. There
    are way cleaner ways of getting your stuff to work in all browser windows.

    --
    --
    ~kaeli~
    No one is listening until you make a mistake.



    Comment

    • David Dorward

      #3
      Re: Finding browser screen width

      kaeli wrote:
      [color=blue][color=green]
      >> What is best way to find browser screen width[/color][/color]
      [color=blue]
      > Why would you need it, anyway?
      > Good coding would have content fit readably no matter the width.[/color]

      Well, I'm planning some photo gallery software which will use the window
      size to select a default image size (which the user can override if they so
      wish). So there are some reasonable uses for it :)

      --
      David Dorward <http://blog.dorward.me .uk/> <http://dorward.me.uk/>
      Home is where the ~/.bashrc is

      Comment

      • kaeli

        #4
        Re: Finding browser screen width

        In article <cmp05i$4tb$1$8 30fa17d@news.de mon.co.uk>, dorward@yahoo.c om
        enlightened us with...[color=blue]
        > kaeli wrote:
        >[color=green][color=darkred]
        > >> What is best way to find browser screen width[/color][/color]
        >[color=green]
        > > Why would you need it, anyway?
        > > Good coding would have content fit readably no matter the width.[/color]
        >
        > Well, I'm planning some photo gallery software which will use the window
        > size to select a default image size (which the user can override if they so
        > wish). So there are some reasonable uses for it :)
        >
        >[/color]

        Well, then, post your screen size detecting code for the OP. ;)

        --
        --
        ~kaeli~
        Never say, "Oops!"; always say, "Ah, interesting!"



        Comment

        • Oscar Monteiro

          #5
          Re: Finding browser screen width


          "mgandra" <madhumohang@ho tmail.com> escreveu na mensagem
          news:76d3dc08.0 411081053.73021 b13@posting.goo gle.com...[color=blue]
          > What is best way to find browser screen width using javascript that is
          > compatible with all types of browsers.[/color]

          Javascript as a property that tell us the user screen resolution (not the
          browser´s) If is that, you wish to acomplish just do as follow:
          1 - create an input the HTML body
          <body>
          <input size="50" name="wathevery ouwish">
          <input type="button" value="Resoluti on" onclick="dofunc tion()">

          2- create a script with function to capture screen resolution

          <script type="text/javascript">

          width=screen.wi dth
          height=screen.h eight

          function dofunction()
          {
          watheveryouwish .value="You´re screen resolution is " +width+"*"+heig ht
          }

          </script>



          Comment

          • Mark Preston

            #6
            Re: Finding browser screen width

            mgandra wrote:
            [color=blue]
            > What is best way to find browser screen width using javascript that is
            > compatible with all types of browsers.[/color]

            The best way is to leave the browser window size the hell alone. It
            isn't your browser and it isn't on your PC so stop trying to interfere
            with what other people have chosen to do. Instead, use percentage sizes
            for the components of your web page so that they fit into whatever space
            the user chooses to let you use.

            Comment

            • David Dorward

              #7
              Re: Finding browser screen width

              kaeli wrote:
              [color=blue][color=green]
              >> Well, I'm planning[/color][/color]
              [color=blue]
              > Well, then, post your screen size detecting code for the OP. ;)[/color]

              I've got to write the indexing and scaling Perl first :)

              --
              David Dorward <http://blog.dorward.me .uk/> <http://dorward.me.uk/>
              Home is where the ~/.bashrc is

              Comment

              Working...