Hidden doesn't hide table borders

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

    Hidden doesn't hide table borders

    I posted a very long message regarding my experiences with JavaScript,
    one reply was posted asking I post an example of the problem -- and
    both are gone! Is there a moderator that removes such stuff?

    In any case, here is the issue in brief:

    I want to keep the page invisible while my onload script decides how
    to format it, setting colors, downloads images, etc. The style
    "visibility:hid den" in the body tag almost does it -- except non-zero
    table borders still show. The workaround was to set them to zero in
    the page itself and use javascript to set them to the desired value at
    the same time that it makes the page visible.

    But shouldn't the borders be rendered invisible by the body style
    without that?

    Here are stripped versions of the html and the script file it loads.
    Copy both to your disk (watch out for wraparound line breaks!), naming
    the script file "scripfile. js", doubleclick the .html file, and you'll
    see it happen, since I put in an "alert" at the top of the script to
    let you view the page before the startup code formats it and makes it
    visible.

    BTW: I'm on IE 6.0.


    example.html:
    -------------

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
    "http://www.w3.org/TR/1998/REC-html40-19980424/loose.dtd">

    <html>
    <head><meta content="text/html; charset=UTF-8">
    <SCRIPT LANGUAGE="JavaS cript" src="scriptfile .js">
    </SCRIPT>
    <title>Pricin g</title>
    <STYLE type="text/css">

    </STYLE>

    </head>
    <body style="visibili ty: hidden" OnLoad="javascr ipt:startup()">
    <basefont>

    <table id="bprods" align="center" width="85" border="3" rules="rows"
    cellspacing="0" cellpadding="0" >
    <colgroup align="right" valign="center" >
    <col width="35">
    <col width="45">
    <tr><td>Qty<td> Price</tr>
    <tr><td><inpu t type="text" size="1" maxlength=2 value="1"
    onkeyup="setpri ce(this);" onblur="checkpr ice(this);"><td
    class="pr">99.9 9</tr>
    <tr><td><inpu t type="text" size="1" maxlength=2 value="1"
    onkeyup="setpri ce(this);" onblur="checkpr ice(this);"><td
    class="pr">231. 42</tr>
    </table>

    </body>
    </html>


    scriptfile.js:
    --------------


    // global variables
    var prices = new Array();
    var entered;
    function startup() {

    alert("startup" );
    // in the real page, there are graphics being downloaded, scripting of
    them to be run,
    // etc., that I don't want the user to see until it's all set up.
    // also, the actual script selects the styles to apply, rather than
    just applying
    // the one set of styles here, and I don't want to display the raw
    page without
    // formatting while the graphics are being set up. the process of
    setting up
    // the graphics also chooses the styles, so I can't set them until the
    downloads
    // are complete. and yes, I figured out a way to wait for them to
    complete,
    // that's not germane to this problem.

    // pick up the data for computing prices for selected quantities
    var whereis;
    if (document.getEl ementById("bpro ds") ) {
    for (var i=1; i<bprods.rows.l ength; i++) {
    whereis=bprods. rows[i].cells[1].sourceIndex;
    // get rid of commas, any currency sign, other text not part of the
    price
    prices[whereis] =
    Number(document .all[whereis].innerText.repl ace(/[^0-9.]/g,''));
    document.all[whereis].innerText =
    (Number(documen t.all[whereis-1].value)*prices[whereis]).toFixed(2);
    }
    }
    // format the page
    document.body.b gColor="#f0f0f0 ";
    document.styleS heets[0].addRule("INPUT ","border:solid ; border-width:
    1; border-color: purple; font-family: Arial; font-style: italic;
    font-weight: bold; color:purple");
    document.styleS heets[0].addRule("TD.pr ","font-family: Arial
    font-style: italic; font-weight: bold; color:purple");
    document.styleS heets[0].addRule("BASEF ONT","font-family: Times;
    font-size: 10pt; color:darkblue; font-style: italic; font-weight:
    bold");
    document.body.s tyle.visibility ="visible";
    }

    function setprice(here) {
    // get the value entered, if it is invalid, get rid of the
    non-numerics -- which
    // puts it back to the value before that last keystroke, so the price
    // already on the page is valid -- issue an alert, and exit.
    // otherwise, get the selling price and display it.

    entered = here.value;
    var vvv = entered.replace (/[^0-9]/g,'');
    if (entered != vvv && entered != '') {
    here.value=vvv;
    alert("Please type a number");
    }
    else {
    if (entered == '') {
    document.all[here.sourceInde x+1].innerText='';
    }
    else {
    document.all[here.sourceInde x+1].innerText=(Num ber(vvv)*prices[here.sourceInde x+1]).toFixed(2);
    }
    }
    entered = '';
    }

    function checkprice(here ) {
    // called when focus disappears from the current INPUT element.
    // if the entry is null or zero, make it 1 and restore the unit
    price.

    if (entered == '' && (here.value == 0 || here.value == "") ) {
    here.value=1;
    document.all[here.sourceInde x+1].innerText=pric es[here.sourceInde x+1];
    }
    }
  • Evertjan.

    #2
    Re: Hidden doesn't hide table borders

    NeverLift wrote on 29 mei 2004 in comp.lang.javas cript:
    [color=blue]
    > I posted a very long message regarding my experiences with JavaScript,
    > one reply was posted asking I post an example of the problem -- and
    > both are gone! Is there a moderator that removes such stuff?[/color]

    No
    [color=blue]
    > In any case, here is the issue in brief:
    >
    > I want to keep the page invisible while my onload script decides how
    > to format it, setting colors, downloads images, etc. The style
    > "visibility:hid den" in the body tag almost does it -- except non-zero
    > table borders still show. The workaround was to set them to zero in[/color]

    Do not use css-styles and older attributes together.
    [this is your problem]

    set the <table border=0

    pack all styles in the <style> and use css classes

    Do not use OnLoad="javascr ipt:startup()" but
    OnLoad="startup ()"

    Do not use LANGUAGE="JavaS cript" but
    type="text/javascript"

    =============== ===============

    <script type="text/javascript src="scriptfile .js">
    </script>

    <style type="text/css">
    body {visibility:hid den;}
    .mytable {border:solid 1px black;width:85p x;}
    .mytable td {border:dotted 1px black;text-align:center;pa dding:0;}
    </style>

    </head>
    <body onLoad="startup ()">
    <table id="bprods" class="mytable" border="0" rules="rows"
    cellspacing="0" cellpadding="0" >
    etc...

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)

    Comment

    • Martin Sammtleben

      #3
      Re: Hidden doesn't hide table borders

      In article <9801f4ab.04052 91151.6c4795b1@ posting.google. com>,
      gary@labdata.co m (NeverLift) wrote:
      [color=blue]
      > The style
      > "visibility:hid den" in the body tag almost does it[/color]

      Have you experimented with "display:no ne" ?

      Cheers Martin

      --
      To reply by e-mail remove the "waste bin".

      Comment

      • Gary Marquart

        #4
        Re: Hidden doesn't hide table borders

        Well, what is interesting is that, in that code itself, unless one
        specifies border="0" in the page definition -- they still bleed through
        the hidden status of the body! Further, the tables continue to have no
        borders after the startup completes and Hidden is changed, in spite of
        the style entry -- unless the script explicitly sets the border value
        back to some non-zero value.

        So it seems my workaround is still needed, so I'll stick with what
        works. Not a big deal, but I consider that allowing ANY of the content
        of a hidden body to be rendered visible to be a bug. (Haven't tried it
        in NN, just IE 6.0.)

        But I thank you for clearing up some of my out-of-date context.

        {aka NeverLift}

        (frequently confused, but never deprecated)

        {Some day I'm going to track down Peer and reset HIS connection.}

        *** Sent via Developersdex http://www.developersdex.com ***
        Don't just participate in USENET...get rewarded for it!

        Comment

        • Evertjan.

          #5
          Re: Hidden doesn't hide table borders

          Gary Marquart wrote on 30 mei 2004 in comp.lang.javas cript:[color=blue]
          > Well, what is interesting is that, in that code itself, unless one
          > specifies border="0" in the page definition -- they still bleed through
          > the hidden status of the body! Further, the tables continue to have no
          > borders after the startup completes and Hidden is changed, in spite of
          > the style entry -- unless the script explicitly sets the border value
          > back to some non-zero value.[/color]

          [please quote a relevant pert of the posting you answer upon, for the sake
          of other readers. This is not email]

          I always specify border=0 except when testing for my own eyes only.

          Did you try to set [as sugested by someone else]

          body {display:none;}

          instead of the visibility?

          It seems a much better choice in your case



          --
          Evertjan.
          The Netherlands.
          (Please change the x'es to dots in my emailaddress)

          Comment

          • Dr John Stockton

            #6
            Re: Hidden doesn't hide table borders

            JRS: In article <9801f4ab.04052 91151.6c4795b1@ posting.google. com>, seen
            in news:comp.lang. javascript, NeverLift <gary@labdata.c om> posted at
            Sat, 29 May 2004 12:51:18 :
            [color=blue]
            >I posted a very long message regarding my experiences with JavaScript,
            >one reply was posted asking I post an example of the problem -- and
            >both are gone! Is there a moderator that removes such stuff?[/color]

            No.

            Obviously you do not understand the tools that you are using for News.

            Google can be used in a satisfactory manner for News; but if you have a
            computer of your own you would do better, IMHO, to install a proper
            newsreader and use a proper news service using News protocols.


            [color=blue]
            >BTW: I'm on IE 6.0.[/color]

            So who cares? What is important is what the readers of your page are
            using. Here (see FAQ, regularly posted) we assume, as default, that
            script is for the Internet, and should therefore be written for any
            reasonably recent browser. That the failure is visible in IE 6.0 may be
            significant; that you use 6.0 is not. If you are composing for an
            intranet which is 6.0 only, you should say so.



            A low-grade trick to achieve the appearance of what you want *might* be
            to start the page with a very tall blank element - conceivably a 1*1 GIF
            with height=9999 - and to remove or shrink the element when all else is
            ready.

            --
            © John Stockton, Surrey, UK. ???@merlyn.demo n.co.uk Turnpike v4.00 MIME. ©
            Web <URL:http://www.merlyn.demo n.co.uk/> - FAQish topics, acronyms, & links.
            Check boilerplate spelling -- error is a public sign of incompetence.
            Never fully trust an article from a poster who gives no full real name.

            Comment

            • Gary Marquart

              #7
              Re: Hidden doesn't hide table borders

              Applause, applause, for Martin. Setting display works like a charm,
              but do ignore what the book says about the default value.

              Put "display:no ne" in the BODY style, restored the table attributes to
              get them they way I want them in the final result -- i.e., with borders.
              Removed resetting the borders from the script.

              Inserted strategic alerts to halt the startup process so I could see the
              incremental effects:

              On load, screen space is totally white. No table borders, nothing.

              During the page formatting, had occasion to set the body background
              color. Whether I used

              document.body.b gColor="#f0f0f0 ";
              or
              document.body.s tyle.background Color="#f0f0f0" ;

              the color was immediately visible. I can live with that :). (Theory:
              If I were using a background image spec, bet that would have been
              visible then as well.)

              Now, to make the page visible, used the CSS manual's declaration of the
              default value of display, "inline". Curious effect: The page was
              rendered correctly except it was not centered within the window, but
              rather hard left. Everything within the body box was correctly placed
              relative to that box, but the box was againsat the left edge. Narrowing
              the window obtained scroll bars like it should (was checking that the
              browser didn't decide to start narrowing elements and word wrapping - at
              this stage I trust nothing to be like I expect . . .)

              But setting display to "block" created the page exactly as expected.

              And away we go.

              BTW: Although a relative newbie (a couple of weeks pushing
              HTML/javascript/DHTML/DOM around, no formal training) (not new to
              programming per se - 40+ year veteran of the wars), I've gotten pretty
              deep into the few parts of this environment that I needed to stretch.
              One of these: Precaching images, and also not allowing the script to
              progress until all were loaded, whether the browser found them in its
              local cache or had to go to the server. With IE's multithreading of
              server requests -- and I assume NN does the same -- this is kinda cute
              to accomplish, especially since I fully expect some of the images to be
              missing, and that the downloading is in process or that the image
              doesn't exist on the server are indistinguishab le states; both give a
              length of -1. To those of you who have done it before, it may be
              considered a Grade 2 exercise. But I'll post if there's a request.

              {aka NeverLift}

              *** Sent via Developersdex http://www.developersdex.com ***
              Don't just participate in USENET...get rewarded for it!

              Comment

              • Gary Marquart

                #8
                Re: Hidden doesn't hide table borders

                Last post was sloppy, sorry. Not "length", of course, but "fileSize".

                Just realized that is IE specific, will switch to some other property.
                Such as "complete"? Duh.

                Comment

                Working...