How to detect table width or height?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dennis

    How to detect table width or height?

    Is there some way --using, say, DOM or javascript-- to detect the
    current pixel width and/or height of a relatively sized table or of
    one of its columns or rows. I'm going to be writing javascript to
    adjust my page to the viewer's browser window dimensions and this
    would sure be great information to have.

    Thanks ....
    Dennis


  • Martin Honnen

    #2
    Re: How to detect table width or height?



    Dennis wrote:
    [color=blue]
    > Is there some way --using, say, DOM or javascript-- to detect the
    > current pixel width and/or height of a relatively sized table or of
    > one of its columns or rows. I'm going to be writing javascript to
    > adjust my page to the viewer's browser window dimensions and this
    > would sure be great information to have.[/color]

    With IE4+, Netscape 6+, Opera 7 you can read
    element.offsetW idth
    element.offsetH eight
    of any element in the page. So try
    var element;
    if (document.all)
    element = document.all['elementId'];
    else if (document.getEl ementById)
    element = document.getEle mentById('eleme ntId');
    if (element) {
    // read element.offsetW idth/element.offsetH eight here
    }


    As your question and the answer is not about HTML but JavaScript I have
    crossposted to comp.lang.javas cript and set follow-up to it.

    --

    Martin Honnen


    Comment

    • EightNineThree

      #3
      Re: How to detect table width or height?


      "Dennis" <theonlyDennis@ removeForSpam_m indspring.com> wrote in message
      news:vvifov02qj atl7sdcbqb72jpn leg9udvtc@4ax.c om...[color=blue]
      > Is there some way --using, say, DOM or javascript-- to detect the
      > current pixel width and/or height of a relatively sized table or of
      > one of its columns or rows. I'm going to be writing javascript to
      > adjust my page to the viewer's browser window dimensions and this
      > would sure be great information to have.
      >[/color]

      Why resort to BS javascript trickery when you can just use a flexible
      layout?


      --
      Karl Core

      At times one remains faithful to a cause only because its opponents do not
      cease to be insipid.
      Friedrich Nietzsche

      eightninethree AT eightninethree. com


      Comment

      • Stan Brown

        #4
        Re: How to detect table width or height?

        In article <vvifov02qjatl7 sdcbqb72jpnleg9 udvtc@4ax.com> in
        comp.infosystem s.www.authoring.html, Dennis
        <theonlyDennis@ removeForSpam_m indspring.com> wrote:[color=blue]
        > I'm going to be writing javascript to
        >adjust my page to the viewer's browser window dimensions[/color]

        Oh god, here we go again.

        --
        Stan Brown, Oak Road Systems, Cortland County, New York, USA
        Portal Live Casino Terbaik di DRAGON222! Nikmati taruhan game spesialis Baccarat dan roulette resmi. Mengajak mencari pengalaman bermain yang lebih seru secara online tanpa harus dateng ke casino offline.

        HTML 4.01 spec: http://www.w3.org/TR/html401/
        validator: http://validator.w3.org/
        CSS 2 spec: http://www.w3.org/TR/REC-CSS2/
        2.1 changes: http://www.w3.org/TR/CSS21/changes.html
        validator: http://jigsaw.w3.org/css-validator/

        Comment

        • Brian

          #5
          Re: How to detect table width or height?

          Stan Brown wrote:[color=blue]
          > In article <vvifov02qjatl7 sdcbqb72jpnleg9 udvtc@4ax.com> in
          > comp.infosystem s.www.authoring.html, Dennis
          > <theonlyDennis@ removeForSpam_m indspring.com> wrote:
          >[color=green]
          >>I'm going to be writing javascript to
          >>adjust my page to the viewer's browser window dimensions[/color]
          >
          > Oh god, here we go again.[/color]

          Not me. I'm steering clear of this one. :) (Note to op: use Google
          to search for recent threads on resolution, browser window, and design.)

          --
          Brian
          follow the directions in my address to email me

          Comment

          • Dennis

            #6
            Re: How to detect table width or height?

            I have a long list to put up, and I want as much of it as possible to
            be viewable to the user without scrolling. So the wider the user's
            window, the more columns I can put up. Now, if there was a setting
            that would collapse a table's column at a given width, I could work
            with it that way too, but I'd still need javascript to find out how
            many columns had been collapsed (eg, had 0 width) --so I'm sort of
            back where I started.

            On Sat, 11 Oct 2003 08:15:44 -0400, "EightNineThree " <uce@ftc.gov>
            wrote:
            [color=blue]
            >Why resort to BS javascript trickery when you can just use a flexible
            >layout?[/color]

            Comment

            • Eric Bohlman

              #7
              Re: How to detect table width or height?

              Dennis <theonlyDennis@ removeForSpam_m indspring.com> wrote in
              news:opcgovc949 1hmjb8mvf6db7ad b1117q3mr@4ax.c om:
              [color=blue]
              > I have a long list to put up, and I want as much of it as possible to
              > be viewable to the user without scrolling. So the wider the user's
              > window, the more columns I can put up. Now, if there was a setting
              > that would collapse a table's column at a given width, I could work
              > with it that way too, but I'd still need javascript to find out how
              > many columns had been collapsed (eg, had 0 width) --so I'm sort of
              > back where I started.[/color]

              I think we've got an "XY problem" here. An XY problem occurs when there's
              confusion between ends and means. Your first problem states your goal in
              general terms: you want the user to be able to see as much of your list as
              possible without scrolling. That sounds, in the absence of more specific
              information about your application, like a reasonable goal. Your next
              sentence gets a little more specific: you want to display the list in
              columns, with the number of columns increasing with browsing window size.
              That's starting to move from ends to means, but it still sounds like a
              fairly reasonable implementation. So your "X" is that you want to display
              a list as multiple columns, with the number of columns varying according to
              window width.

              However, you've now jumped from that requirement to the notion that you
              need a table to do it, and that you need to dynamically resize the table
              with scripting in order to do it. That's your "Y" (a specific
              implementation) , but it's not necessarily the only means of achieving your
              end. There may be some "Z" that would do a better job. A lot of people
              here, through their own sometimes bitter experience, realize that the
              particular "Y" you've picked tends to be difficult and unreliable in
              practice.

              The solution is to tell us about your "X" in more detail. There's a very
              good chance that if you do, one or more people here will recognize that
              they've already solved the problem in some way that doesn't resemble your
              "Y" at all and they'll show you how.

              Comment

              • Dennis

                #8
                Re: How to detect table width or height?

                Sure, I'm for anything that works. I got into the table idea because
                I've read that detecting the user's overall browser window dimensions
                (speaking of X,Y ...) can't be reliably done --or at least efficiently
                done without a ton of code. And that was my initital "Y" approach.
                My objective here is to have the number of columns increase so as to
                accomodate the user's browser width. Actually, given the importance
                of reading text, you would think HTML would have a "multi-column wrap"
                feature, but apparently it doesn't.

                Dennis

                On 11 Oct 2003 18:23:53 GMT, Eric Bohlman <ebohlman@earth link.net>
                wrote:
                [color=blue]
                >Dennis <theonlyDennis@ removeForSpam_m indspring.com> wrote in
                >news:opcgovc94 91hmjb8mvf6db7a db1117q3mr@4ax. com:
                >[color=green]
                >> I have a long list to put up, and I want as much of it as possible to
                >> be viewable to the user without scrolling. So the wider the user's
                >> window, the more columns I can put up. Now, if there was a setting
                >> that would collapse a table's column at a given width, I could work
                >> with it that way too, but I'd still need javascript to find out how
                >> many columns had been collapsed (eg, had 0 width) --so I'm sort of
                >> back where I started.[/color]
                >
                >I think we've got an "XY problem" here. An XY problem occurs when there's
                >confusion between ends and means. Your first problem states your goal in
                >general terms: you want the user to be able to see as much of your list as
                >possible without scrolling. That sounds, in the absence of more specific
                >information about your application, like a reasonable goal. Your next
                >sentence gets a little more specific: you want to display the list in
                >columns, with the number of columns increasing with browsing window size.
                >That's starting to move from ends to means, but it still sounds like a
                >fairly reasonable implementation. So your "X" is that you want to display
                >a list as multiple columns, with the number of columns varying according to
                >window width.
                >
                >However, you've now jumped from that requirement to the notion that you
                >need a table to do it, and that you need to dynamically resize the table
                >with scripting in order to do it. That's your "Y" (a specific
                >implementation ), but it's not necessarily the only means of achieving your
                >end. There may be some "Z" that would do a better job. A lot of people
                >here, through their own sometimes bitter experience, realize that the
                >particular "Y" you've picked tends to be difficult and unreliable in
                >practice.
                >
                >The solution is to tell us about your "X" in more detail. There's a very
                >good chance that if you do, one or more people here will recognize that
                >they've already solved the problem in some way that doesn't resemble your
                >"Y" at all and they'll show you how.[/color]

                Comment

                • William Tasso

                  #9
                  Re: How to detect table width or height?

                  Dennis wrote:

                  Please don't top-post.
                  [color=blue]
                  > ...
                  > My objective here is to have the number of columns increase so as to
                  > accomodate the user's browser width.[/color]

                  set a width to the elements in question and employ CSS: float

                  --
                  William Tasso


                  Comment

                  • Barry Pearson

                    #10
                    Re: How to detect table width or height?

                    Brian wrote:
                    [snip][color=blue]
                    > Not me. I'm steering clear of this one. :) (Note to op: use Google
                    > to search for recent threads on resolution, browser window, and
                    > design.)[/color]

                    Ensure that your read the following, which didn't get an answer from Brian. It
                    asks how a person should decide what size to make pixel-oriented content such
                    as images & photographs:
                    http://groups.google.c om/groups?as_umsgi d=uemfb.519$ux1 .309@newsfep1-gui.server.ntli .net


                    Have a look at one of Brian's own pages:



                    If you view that page, and contract the window on your browser, you will find
                    that, at about 864 viewport pixels, a horizontal scroll-bar appears. Brian's
                    page is really designed for quite large screen sizes. That is partly because
                    of Brian's CSS. Switch off the CSS, and the horizontal scroll-bars don't
                    appear until the viewport width is down to about 688 pixels.

                    The basic reason is simple - the photograph on that page is 661 x 391 pixels.
                    There is nothing wrong with that! There are very few people with 640 x 480
                    screens, so why bother to cater for them? Nearly half of web users have 800 x
                    600 screens, so it is a good idea to cater for them. I cannot fault Brian's
                    decision to base his image size on the screen sizes of the vast majority of
                    web users. IF that is how he arrived at the particular size! (I hope he didn't
                    simply make a random decision).

                    My own view is that, having made the decision to have a photograph size that
                    fits onto the common screen size, it is wrong to cause further problems by
                    requiring even larger screen sizes. I wouldn't have CSS that did that. With my
                    own photograph pages, using photographs that are 700 pixels wide, there are no
                    horizontal scroll-bars at 800 pixels. But - Brian is allowed to choose
                    otherwise - his valid choice.

                    I recently did a brief survey of the widths of web sites. See:
                    http://groups.google.c om/groups?as_umsgi d=%VSgb.426$QA4 .182271@newsfep 1-win.server.ntli .net


                    Right across the world, major web sites have been (and presumably are still
                    being) designed on the assumption that the available screen width is up to 800
                    pixels. There appears to be an implicit assumption that media-type="screen"
                    means "800 pixels", even among people have who never heard of media types.

                    Those 800-pixel-wide web site are of all types. Tableless & tables. With &
                    without CSS. Old & new. Structured with hn, etc, and not. Strict,
                    Transitional, or no DOCTYPES. HTML or XHTML. The paradigm is "screens are up
                    to 800 pixels wide".

                    What are the implications for how we should write HTML & CSS?

                    --
                    Barry Pearson


                    This site provides information & analysis of child support & the Child Support Agency in the UK, mainly for lobbyists, politicians, academics & media.



                    Comment

                    • Brian

                      #11
                      Re: How to detect table width or height?

                      Barry Pearson wrote:[color=blue]
                      > Brian wrote:
                      >
                      > Ensure that your read the following, which didn't get an answer from Brian.[/color]

                      Was I under some obligation? Why didn't anyone tell me?
                      [color=blue]
                      > It asks how a person should decide what size to make
                      > pixel-oriented content such as images & photographs:
                      > http://groups.google.c om/groups?as_umsgi d=uemfb.519$ux1 .309@newsfep1-gui.server.ntli .ne
                      > http://tinyurl.com/qkqe[/color]

                      Oh, one more thing: how much will you pay me when I provide the answer
                      you feel you deserve?
                      [color=blue]
                      > Have a look at one of Brian's own pages:
                      > http://people.umass.edu/btrembla/jardin/garden.html
                      > http://tinyurl.com/qkqt
                      >
                      > If you view that page, and contract the window on your
                      > browser, you will find that, at about 864 viewport pixels,
                      > a horizontal scroll-bar appears.[/color]

                      This is a flaw in the redesign of my site, in which I moved the
                      navigation from the top to the left of the window, causing a
                      horizontal scroll bar with that big picture. I'd like to thank you
                      for pointing it out, but I get the impression that it's intended to
                      denigrate my work.
                      [color=blue]
                      > I cannot fault Brian's decision to base his image size on
                      > the screen sizes of the vast majority of web users. IF
                      > that is how he arrived at the particular size![/color]

                      It isn't. I don't cater to any screen size.
                      [color=blue]
                      > (I hope he didn't simply make a random decision).[/color]

                      You could just ask me, of course. You didn't, but in case the
                      suspense is killing you, here's how I arrived at my decision: I made
                      the photo as small as I could, both by cropping and shrinking, while
                      maintaining the composition of the photo and keeping the detail.

                      Now, if you'll excuse me, I must go rethink the css on my site.

                      --
                      Brian
                      follow the directions in my address to email me

                      Comment

                      • William Tasso

                        #12
                        Re: How to detect table width or height?

                        Brian wrote:[color=blue]
                        > Barry Pearson wrote:[color=green]
                        >>
                        >> Ensure that your read the following, which didn't get an answer from
                        >> Brian.[/color]
                        >
                        > Was I under some obligation? Why didn't anyone tell me?
                        >[/color]

                        Lost your way Brian?

                        You've been seconded to the help desk - remember? Just down the hall,
                        second on the left.

                        ---------------->

                        --
                        William Tasso - http://WilliamTasso.com


                        Comment

                        • Brian

                          #13
                          Re: How to detect table width or height?

                          William Tasso wrote:[color=blue]
                          >
                          > You've been seconded to the help desk[/color]

                          I don't quite get that. I've been "seconded?" What does "second"
                          mean when used as a verb?

                          --
                          Brian
                          follow the directions in my address to email me

                          Comment

                          • brucie

                            #14
                            Re: How to detect table width or height?

                            In post <Ky3ib.540729$O z4.446392@rwcrn sc54>
                            Brian said...
                            [color=blue][color=green]
                            >> You've been seconded to the help desk[/color][/color]
                            [color=blue]
                            > I don't quite get that. I've been "seconded?" What does "second"
                            > mean when used as a verb?[/color]

                            its one after being firsted and one before being thirded

                            --
                            brucie.
                            12/October/2003 01:11:26 pm

                            Comment

                            • Stan Brown

                              #15
                              seconded (Re: How to detect table width or height?)

                              In article <Ky3ib.540729$O z4.446392@rwcrn sc54> in
                              comp.infosystem s.www.authoring.html, Brian
                              <usenet1@mangym utt.com.invalid-remove-this-part> wrote:[color=blue]
                              >William Tasso wrote:[color=green]
                              >>
                              >> You've been seconded to the help desk[/color]
                              >
                              >I don't quite get that. I've been "seconded?" What does "second"
                              >mean when used as a verb?[/color]


                              and look at the fourth meaning under tr[ansitive]v[erb]

                              The acCENT is on the second sylLABle, at least in the past
                              participle. I've never heard the verb used in the present tense.

                              The noun form is "seCONDment ":


                              --
                              Stan Brown, Oak Road Systems, Cortland County, New York, USA
                              Portal Live Casino Terbaik di DRAGON222! Nikmati taruhan game spesialis Baccarat dan roulette resmi. Mengajak mencari pengalaman bermain yang lebih seru secara online tanpa harus dateng ke casino offline.

                              HTML 4.01 spec: http://www.w3.org/TR/html401/
                              validator: http://validator.w3.org/
                              CSS 2 spec: http://www.w3.org/TR/REC-CSS2/
                              2.1 changes: http://www.w3.org/TR/CSS21/changes.html
                              validator: http://jigsaw.w3.org/css-validator/

                              Comment

                              Working...