SitePoint Sponsor

User Tag List

Results 1 to 12 of 12
  1. #1
    Rehab is for quiters! spartan's Avatar
    Join Date
    Apr 2002
    Location
    Cape Town, South Africa
    Posts
    343
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    get the screensize...

    how can i get the users screensize and resolution?
    Spartan
    ---------------------
    It's like our sergeant told us before one trip into the jungle. Men! Fifty of you are leaving on a mission. Twenty-five of you ain't coming back.
    -Mr.Payne

  2. #2
    SitePoint Addict ThomasAesir's Avatar
    Join Date
    May 2002
    Location
    Sydney, Australia
    Posts
    214
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This should do the trick:

    <script Language="JavaScript">
    var x = screen.width;
    var y = screen.height;
    </script>
    Thomas Oeser - Blueprint Software
    Web Scripting Editor v 5.2 One cool Web editing tool.
    3dcomputergraphics.com Coming Soon!

  3. #3
    Rehab is for quiters! spartan's Avatar
    Join Date
    Apr 2002
    Location
    Cape Town, South Africa
    Posts
    343
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yeah, thanx for the reply.
    just figured it out a couple of minutes ago.

    another question though.

    that would return the actual size of the screen, but when working inside a browser you obviously don't actually have that much space to work with. taking into account scrollbars and toolbars and what not.

    so... how would i get the actuall screen size, INSIDE the browser window(when it is maximised). lets say I had a table with width=100% and the window is maximized... what would the width of that table be)

    hope I explained myself well enough...
    Spartan
    ---------------------
    It's like our sergeant told us before one trip into the jungle. Men! Fifty of you are leaving on a mission. Twenty-five of you ain't coming back.
    -Mr.Payne

  4. #4
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The properties of the screen are hard to get at sometimes.

    I normally use outterWidth innerWidth pixelWidth screenWidth offsetWidth etc

    Normally screen.availWidth gets your screen width.
    BUT ... this doesn't work on dual head double pane
    systems ( like mine, where one screen is 1280 and the other 1024 making 2304 in total )

    And unfortunately i can't remember Just how to do that right now.
    When i do - i'll come back

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  5. #5
    Rehab is for quiters! spartan's Avatar
    Join Date
    Apr 2002
    Location
    Cape Town, South Africa
    Posts
    343
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    BTW... does javascript have something like the replace("string","s","A") function in vbscript??

    or do you have to use regexp... jees seems like I've got thousands of questions today.

    here is one more I'm looking for a javascript equivalent of the cint() function in vbscript

    I wanna do something like this

    thing.style.top = thing.style.top + 10

    but thing.style.top returns 13px or whatever. but it has the 'px' at the end

    i need to get around that somehow...

    any help would be apreciated.

    Thanx

    ps. any links to some kind of javascript syntax help would be great. (teach a man to fish...bla bla bla)
    Spartan
    ---------------------
    It's like our sergeant told us before one trip into the jungle. Men! Fifty of you are leaving on a mission. Twenty-five of you ain't coming back.
    -Mr.Payne

  6. #6
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually the vbscript replace uses the regular expressions section provided by the browser - i believe - and is thus open to JS just as well with the same syntax and methods.

    pixelTop returns a top withtout a px.
    You can then just do
    object.style.pixelTop += amount.

    However this doesn't work in Netscape which can't handle the idea of parsing it's own objects ( well OBVIOUSLY )

    so you'd use:
    object.style.top = ( parseInt(object.style.top) + amount );

    * the () around it makes sure deficient browsers still eval the + ( even though it's obvious ).

    Anyway - i don't mind helping Spartan - my pleasure.

    Ask all you need.

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  7. #7
    Rehab is for quiters! spartan's Avatar
    Join Date
    Apr 2002
    Location
    Cape Town, South Africa
    Posts
    343
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanx Flawless,

    that parseInt() function is actually just what I was looking for. Spent about a hour going through old scripts in my code library, cause I knew I had used it before.

    I'm just so used to vbscript and asp at the mo

    don't think I'll be going back to using vbscript ever again... although I guess I'll still end up using it server side.

    thanx for the help...

    cheers
    Spartan
    ---------------------
    It's like our sergeant told us before one trip into the jungle. Men! Fifty of you are leaving on a mission. Twenty-five of you ain't coming back.
    -Mr.Payne

  8. #8
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Who's the photo of, you or Michael Rosenbaum - by the way?

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  9. #9
    Rehab is for quiters! spartan's Avatar
    Join Date
    Apr 2002
    Location
    Cape Town, South Africa
    Posts
    343
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hehe

    nah, its Michael...(Lex Luthor)...

    the pic I wanted to use didn't fit and I never got around to changing it after that.

    you a smallville fan?
    Spartan
    ---------------------
    It's like our sergeant told us before one trip into the jungle. Men! Fifty of you are leaving on a mission. Twenty-five of you ain't coming back.
    -Mr.Payne

  10. #10
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Huge one... but don't tell me what happens after the
    first series - we don't get it on terestrial for a while here

    he he

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  11. #11
    Rehab is for quiters! spartan's Avatar
    Join Date
    Apr 2002
    Location
    Cape Town, South Africa
    Posts
    343
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    neither do we.
    Actuallty the first series hasn't even hit local tv over here yet..

    had to download every episode!

    worth it though
    Spartan
    ---------------------
    It's like our sergeant told us before one trip into the jungle. Men! Fifty of you are leaving on a mission. Twenty-five of you ain't coming back.
    -Mr.Payne

  12. #12
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    he he - now THAT'S real dedication.

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---


Bookmarks

Posting Permissions

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