Detect Browser Dimension

Discussion in 'Ruby' started by ceedub.industries@gmail.com, Dec 15, 2005.

  1. Guest

    Dear all,

    I've just been turned on to Ruby and am trying to code a first Ruby
    CGI. I've already hit a brick wall.

    I'm looking to see if there is a method similar to PHP's screen.width()
    and screen.height() so I can dynamically send different sized pictures
    depending on the agent's screen resolution.

    -Christopher
     
    , Dec 15, 2005
    #1
    1. Advertising

  2. ako... Guest

    CGI is a code that executes on the server. the server does not know
    anything about the client that submits a request unless the client
    tells it about itself. there is no way to find out the screen size of
    the client's browser unless the client side code submits a request to
    the CGI containing the dimentions. the client even can have no browser
    at all as far as the CGI script is concerned.

    konstantin
     
    ako..., Dec 15, 2005
    #2
    1. Advertising

  3. wrote:
    > Dear all,
    >
    > I've just been turned on to Ruby and am trying to code a first Ruby
    > CGI. I've already hit a brick wall.
    >
    > I'm looking to see if there is a method similar to PHP's screen.width()
    > and screen.height() so I can dynamically send different sized pictures
    > depending on the agent's screen resolution.
    >
    > -Christopher
    >
    >

    One way to do this would be to use Javascript's screen.width and
    screen.height to set some hidden input values and then read those with
    the CGI script.

    -Justin
     
    Justin Collins, Dec 16, 2005
    #3
  4. Adam Sroka Guest

    Justin Collins wrote:
    > wrote:
    >> Dear all,
    >>
    >> I've just been turned on to Ruby and am trying to code a first Ruby
    >> CGI. I've already hit a brick wall.
    >>
    >> I'm looking to see if there is a method similar to PHP's screen.width()
    >> and screen.height() so I can dynamically send different sized pictures
    >> depending on the agent's screen resolution.
    >>
    >> -Christopher
    >>
    >>

    > One way to do this would be to use Javascript's screen.width and
    > screen.height to set some hidden input values and then read those with
    > the CGI script.
    >
    > -Justin
    >
    > .
    >

    A more modern approach would be to use an AJAX request to send the
    values to the server side. You could do this onload(), and then again
    onresize() (Supported by all but Opera.) Of course, if you're using
    Javascript you could make most adjustments on the page and avoid the
    round trip (Unless the issue *requires* a server side adjustment, like
    building a graphic on the fly or something.)
     
    Adam Sroka, Dec 16, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Max

    dimension of an integer

    Max, Sep 19, 2003, in forum: VHDL
    Replies:
    4
    Views:
    523
  2. Replies:
    2
    Views:
    8,680
    Jim Lewis
    Mar 21, 2006
  3. Shapper

    Array Dimension

    Shapper, Jun 7, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    474
    =?Utf-8?B?RGF2aWQgQW50b24=?=
    Jun 8, 2005
  4. Luuk
    Replies:
    15
    Views:
    835
    Nobody
    Feb 11, 2010
  5. Replies:
    0
    Views:
    504
Loading...

Share This Page