Results 1 to 8 of 8

Thread: Get the Screen size of a User?

  1. #1

    Thread Starter
    PowerPoster Pc_Madness's Avatar
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    2,765

    Get the Screen size of a User?

    Is it possible to get the screen resolution the user it running? I was hoping to create some page content in PHP and then no where to position it based off how much space will appear (the page is centered so I'll have room on the left and right).

    I guess I could get the page size with Javascript and then do a redirect, but thats really crappy, and trying to limit how much Javascript I use.
    Don't Rate my posts.

  2. #2
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Get the Screen size of a User?

    Like you said, the only way to do this is through Javascript. There is nothing wrong with using Javascript if the browser supports it. The way to do it is to get the page looking as close as possible without Javascript, then, put a small script at the bottom of the page which resizes the content accordingly.

    By coding for the lowest common denominator and building the more enhanced functionality such as CSS and Javascript on top you can be sue the the page will always display.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  3. #3

    Thread Starter
    PowerPoster Pc_Madness's Avatar
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    2,765

    Re: Get the Screen size of a User?

    I really don't like Javascript though, it can really give bad performance on low end comps.

    I swear I thought I saw a way to get the size with the headers? How do all those traffic generators get there hit details, JS as well?
    Don't Rate my posts.

  4. #4
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Get the Screen size of a User?

    Quote Originally Posted by Pc_Madness
    I really don't like Javascript though, it can really give bad performance on low end comps.
    What gives you this idea? - What do you class as low end?

    A Few browsers, namely text based, not including IE and Firefox, will pass the screen resolution in the User Agent string, but, rarely, of what use will this be, if you do not know the Window Size.

    The best thing to do is, design for your lowest resolution maybe 800x600 and use a small piece of JS at the bottom to resize appropriately, and no, it does not slow it down, the JS interpreter is loaded into memory when the browser starts, so unless your users are using Pentium 2 machines with only 24Mb of RAM, the performance hit is negligible.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  5. #5

    Thread Starter
    PowerPoster Pc_Madness's Avatar
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    2,765

    Re: Get the Screen size of a User?

    Quote Originally Posted by visualAd
    What gives you this idea? - What do you class as low end?

    A Few browsers, namely text based, not including IE and Firefox, will pass the screen resolution in the User Agent string, but, rarely, of what use will this be, if you do not know the Window Size.

    The best thing to do is, design for your lowest resolution maybe 800x600 and use a small piece of JS at the bottom to resize appropriately, and no, it does not slow it down, the JS interpreter is loaded into memory when the browser starts, so unless your users are using Pentium 2 machines with only 24Mb of RAM, the performance hit is negligible.
    Well most people have there window at full screen, I dunno I'm not looking for something perfect.. I dunno will take a proper look at it later and see what I can knock up.

    My Cel 1.1 with 256mb ram (xp) used to be aware of very Javascript pages, chuggy ness
    Don't Rate my posts.

  6. #6
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Get the Screen size of a User?

    You'll be surprised how much Javascript is behind the forum's pages . If you have Firefox, disable JS and you'll see how different the page looks.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  7. #7
    Hyperactive Member PlaGuE's Avatar
    Join Date
    Jun 2005
    Location
    in ur mind.
    Posts
    445

    Re: Get the Screen size of a User?

    the only thing i see change is the "VB Wire News" thing at the top.
    Without balance, there could only be chaos.
    Without chaos, there could be no balance.
    I live with karma. Eat with destiny. Dream of life without shackles....
    Yet. If life had no consequences, life could not exist, nor could it flourish.


    If at first you dont succeed.You're screwed.

    C++/Java NOOB.

    I aint a professional at PHP, but if i can help i will.

  8. #8
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Get the Screen size of a User?

    All the thread tools and members options menus will be disabled too.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width