Skip to main content
Inspiring
October 16, 2008
Question

Finding out about window size

  • October 16, 2008
  • 17 replies
  • 3184 views
Hello

I'm trying to find out the window size of the browser visiting my web site. There is several javascript codes but I'm wondering whether there is anything in CF? I checked CFlib and unfortunately didn't find anything....

At the end I would like to have the width and height available for further use. My problem (because I'm a rookie) is to take this information out from javascript to a CF variable (or structure or whatever).... Thats why I prefer not to use javascript at all ;-)

Is there an easy solution?

Thank you very much
    This topic has been closed for replies.

    17 replies

    Inspiring
    October 16, 2008
    tomtomtom wrote:
    > Thats why I prefer not to use javascript at all ;-)

    Unfortunately, that is not possible. ColdFusion only runs on the
    server. It knows nothing of clients such as window dimensions. You
    must do this with JavaScript.

    >
    > Is there an easy solution?

    Any of those JavaScript codes you found should be fine.

    Just remember, JavaScript is only on the client. It knows nothing of
    servers. To get this information from the client to the server you will
    need to do something to get it there. All the normal channels are fine.
    Submit the information in a request with post or get. Save it to a
    cookie. Make a new request -- even one behind the scenes with Ajax.

    But until the client collects this information and sends it to the
    server in a request, ColdFusion will have no idea.

    Inspiring
    October 21, 2008
    Hello Ian

    Many thanks for your input. So far I'm able to display the viewport size by Javascript (see code) on the client. At the end I would like to have it in a request variable as you said. But I still have no idea on how to do this! can ou furnish an example (please step by step with the starting point being my javascript).
    At the very end I would lik to have something like: <cfset myViewportWidth = #noidea#>

    I would be very thankful...
    October 16, 2008
    You will need javascript to return the window height width values. If you need to retain that information for future use, you could simply submit the value into your database.