Should I use browser detection code or not?

Discussion in 'Javascript' started by delerious@no.spam.com, Dec 8, 2003.

  1. Guest

    I want to know the height of the viewable portion of a page (minus scrollbar)
    in Opera and Mozilla.

    For Opera, I could use document.body.clientHeight. Unfortunately, this won't
    work in Mozilla because Mozilla also subtracts the sizes of the top and bottom
    margins.

    For Mozilla, I could use document.documentElement.clientHeight.
    Unfortunately, this won't work in Opera because Opera returns the height of
    the entire page, not just the viewable portion.

    So I have two options:

    1) Use browser detection code to determine if the user is running Opera or
    Mozilla, and then use the appropriate clientHeight code.

    2) Use window.innerHeight. This is supported by both Opera and Mozilla,
    however it returns the height of the viewable portion of the page *including*
    the scrollbar. Is there any way to determine the width of a scrollbar? If
    not, then I would have to make an assumption and subtract the hardcoded width
    of the scrollbar from window.innerHeight... but only if the scrollbar is
    present, is there a way to determine that?
    , Dec 8, 2003
    #1
    1. Advertising

  2. wrote:

    > I want to know the height of the viewable portion of a page (minus scrollbar)
    > in Opera and Mozilla.


    Before we go on I would like to know why do you think you need to know
    that and to see your munged `From:' header replaced with something that
    conforms to Internet/Usenet standards.[1]


    PointedEars
    ___________
    [1] http://www.interhack.net/pubs/munging-harmful/
    Thomas 'PointedEars' Lahn, Dec 8, 2003
    #2
    1. Advertising

  3. JRS: In article <>, seen in
    news:comp.lang.javascript, Thomas 'PointedEars' Lahn
    <> posted at Tue, 9 Dec 2003 00:26:50 :-
    > wrote:
    >
    >> I want to know the height of the viewable portion of a page (minus scrollbar)
    >> in Opera and Mozilla.

    >
    >Before we go on I would like to know why do you think you need to know
    >that and to see your munged `From:' header replaced with something that
    >conforms to Internet/Usenet standards.[1]



    OP : ignore that. TL is obsessed.

    --
    © John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
    <URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang.javascript
    <URL:http://www.merlyn.demon.co.uk/js-index.htm> JSc maths, dates, sources.
    <URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/JSc/&c, FAQ topics, links.
    Dr John Stockton, Dec 9, 2003
    #3
  4. Dr John Stockton wrote:

    > Thomas 'PointedEars' Lahn
    >> wrote:
    >>> I want to know the height of the viewable portion of a page (minus scrollbar)
    >>> in Opera and Mozilla.

    >>
    >> Before we go on I would like to know why do you think you need to know
    >> that and to see your munged `From:' header replaced with something that
    >> conforms to Internet/Usenet standards.[1]

    >
    > OP : ignore that. TL is obsessed.


    Read you again in a few weeks.


    PointedEars
    Thomas 'PointedEars' Lahn, Dec 9, 2003
    #4
  5. JRS: In article <>, seen in
    news:comp.lang.javascript, Thomas 'PointedEars' Lahn
    <> posted at Wed, 10 Dec 2003 00:04:39 :-
    >Dr John Stockton wrote:
    >
    >> Thomas 'PointedEars' Lahn
    >>> wrote:
    >>>> I want to know the height of the viewable portion of a page (minus

    >scrollbar)
    >>>> in Opera and Mozilla.
    >>>
    >>> Before we go on I would like to know why do you think you need to know
    >>> that and to see your munged `From:' header replaced with something that
    >>> conforms to Internet/Usenet standards.[1]

    >>
    >> OP : ignore that. TL is obsessed.

    >
    >Read you again in a few weeks.


    Refusal to read refutations is a sign of weakness of stance.

    However, it will do no harm, since the intent is to inform the OP rather
    than to educate TL.

    He is probably still miffed because he cannot understand how my E-mail
    system is standards-compliant.

    --
    © John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
    <URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang.javascript
    <URL:http://www.merlyn.demon.co.uk/js-index.htm> JSc maths, dates, sources.
    <URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/JSc/&c, FAQ topics, links.
    Dr John Stockton, Dec 10, 2003
    #5
    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. Phil Townsend

    browser detection for mobile devices

    Phil Townsend, Dec 2, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    735
    bruce barker
    Dec 2, 2004
  2. Carlos
    Replies:
    4
    Views:
    21,899
    amimpat
    Aug 11, 2009
  3. Josef 'Jupp' SCHUGT

    What the FAQs should and should not contain

    Josef 'Jupp' SCHUGT, Aug 19, 2005, in forum: Ruby
    Replies:
    0
    Views:
    193
    Josef 'Jupp' SCHUGT
    Aug 19, 2005
  4. botp
    Replies:
    6
    Views:
    212
    Joel VanderWerf
    Oct 5, 2010
  5. Michael Winter

    A valid use for browser detection?

    Michael Winter, Feb 3, 2004, in forum: Javascript
    Replies:
    7
    Views:
    108
    Jim Ley
    Feb 4, 2004
Loading...

Share This Page