Javascript and when it is executed...

Discussion in 'Javascript' started by Sonnich Jensen, Aug 24, 2007.

  1. Hi!

    Not sure whether it is the right solution, but this is what I cam up
    with.

    A header and an image for waiting...
    <img src="bigrotation2.gif" name="load1">

    then, when loaded, it should set the height to 0, or something.

    But
    <body onload="load1.height=0;">
    does not work - though executed (tested with an alert as first thing)

    And trying this
    </table><p>
    <script language="JavaScript" type="text/JavaScript"><!--
    load1.height=0;
    --></script>
    when the table has loaded, did not work - the script (again tested
    with an alert) is excuted _before_ the table is loaded. Not sure how
    that is possible, as the code is not even sent to the user yet. (why?)

    I usually work in PHP.

    Basically, I want to set the height to 0 once loaded. Any ideas?

    BR
    Sonnich
     
    Sonnich Jensen, Aug 24, 2007
    #1
    1. Advertising

  2. Sonnich Jensen wrote:
    > Not sure whether it is the right solution, but this is what I cam up
    > with.


    For what problem?

    > A header and an image for waiting...
    > <img src="bigrotation2.gif" name="load1">


    The required `alt' attribute is missing. http://validator.w3.org/

    > then, when loaded, it should set the height to 0, or something.


    Why?

    > But
    > <body onload="load1.height=0;">
    > does not work - though executed (tested with an alert as first thing)


    As it should. You are assuming that because the MSHTML DOM makes element
    object references available as properties of a host object in the scope
    chain, it is so in all UAs. It isn't.

    document.images["load1"].height = 0;

    may work.

    > And trying this
    > </table><p>
    > <script language="JavaScript" type="text/JavaScript"><!--


    Omit the deprecated `language' attribute and the error-prone pseudo-comment
    declaration. A `p' element also should not contain a `script' element
    because if script support is absent, the paragraph spacing is displayed anyway.

    > load1.height=0;
    > --></script>


    The closing pseudo-comment is a syntax error. Remove it.

    > when the table has loaded, did not work -


    http://www.jibbering.com/faq/faq_notes/clj_posts.html#ps1DontWork

    > the script (again tested with an alert) is excuted _before_ the table
    > is loaded.


    Unlikely. It may be executed before the table is fully rendered.

    > Not sure how that is possible, as the code is not even sent to the
    > user yet. (why?)


    Have you removed the `onload' attribute from the `body' element before
    testing the second approach?

    > I usually work in PHP.


    That is irrelevant, as you generate (X)HTML.

    > Basically, I want to set the height to 0 once loaded. Any ideas?


    HTH


    PointedEars
    --
    Anyone who slaps a 'this page is best viewed with Browser X' label on
    a Web page appears to be yearning for the bad old days, before the Web,
    when you had very little chance of reading a document written on another
    computer, another word processor, or another network. -- Tim Berners-Lee
     
    Thomas 'PointedEars' Lahn, Aug 24, 2007
    #2
    1. Advertising

  3. On Aug 24, 4:19 pm, Thomas 'PointedEars' Lahn <>
    wrote:
    > Sonnich Jensen wrote:
    > > Not sure whether it is the right solution, but this is what I cam up
    > > with.

    > For what problem?


    It takes ~5 secs to load the page. A wait.... thing

    > > A header and an image for waiting...
    > > <img src="bigrotation2.gif" name="load1">

    > The required `alt' attribute is missing. http://validator.w3.org/

    Added.

    > > then, when loaded, it should set the height to 0, or something.

    > Why?


    No waiting anymore...
    Or, I could "remove" then waiting img.

    > > But
    > > <body onload="load1.height=0;">
    > > does not work - though executed (tested with an alert as first thing)

    > As it should. You are assuming that because the MSHTML DOM makes element
    > object references available as properties of a host object in the scope
    > chain, it is so in all UAs. It isn't.
    > document.images["load1"].height = 0;
    > may work.


    It does.

    >
    > > And trying this
    > > </table><p>
    > > <script language="JavaScript" type="text/JavaScript"><!--

    >
    > Omit the deprecated `language' attribute and the error-prone pseudo-comment
    > declaration. A `p' element also should not contain a `script' element
    > because if script support is absent, the paragraph spacing is displayed anyway.
    >
    > > load1.height=0;
    > > --></script>

    >
    > The closing pseudo-comment is a syntax error. Remove it.
    >
    > > when the table has loaded, did not work -

    >
    > http://www.jibbering.com/faq/faq_notes/clj_posts.html#ps1DontWork


    :)
    Then they did not make it the way I want it to :-]

    >
    > > the script (again tested with an alert) is excuted _before_ the table
    > > is loaded.

    >
    > Unlikely. It may be executed before the table is fully rendered.


    Took a closer look. Also at the watch. Found out it is friday evening
    and I need a beer.
    Also found, that it was at the end of the wrong table ;-)
    Realised, that I really need that beer.

    Thanks
    Sonnich
     
    Sonnich Jensen, Aug 24, 2007
    #3
  4. Sonnich Jensen wrote:
    > On Aug 24, 4:19 pm, Thomas 'PointedEars' Lahn <>
    > wrote:
    >> Sonnich Jensen wrote:
    >>> Not sure whether it is the right solution, but this is what I cam up
    >>> with.

    >> For what problem?

    >
    > It takes ~5 secs to load the page. A wait.... thing


    I daresay you are trying (and failing) to cure the symptoms here. Why is
    your document this large that it takes ~5 seconds to load? Do you think
    *adding* a wait image will actually *reduce* download/rendering time?

    >>> then, when loaded, it should set the height to 0, or something.

    >> Why?

    >
    > No waiting anymore...
    > Or, I could "remove" then waiting img.


    Good idea :)

    >>> the script (again tested with an alert) is excuted _before_ the table
    >>> is loaded.

    >> Unlikely. It may be executed before the table is fully rendered.

    >
    > Took a closer look. Also at the watch. Found out it is friday evening
    > and I need a beer.
    > Also found, that it was at the end of the wrong table ;-)
    > Realised, that I really need that beer.


    Cheers :)


    \\// PointedEars
    --
    Prototype.js was written by people who don't know javascript for people
    who don't know javascript. People who don't know javascript are not
    the best source of advice on designing systems that use javascript.
    -- Richard Cornford, cljs, <f806at$ail$1$>
     
    Thomas 'PointedEars' Lahn, Aug 24, 2007
    #4
  5. On Aug 24, 4:45 pm, Thomas 'PointedEars' Lahn <>
    wrote:
    > SonnichJensen wrote:
    > > On Aug 24, 4:19 pm, Thomas 'PointedEars' Lahn <>
    > > wrote:
    > >>SonnichJensen wrote:
    > >>> Not sure whether it is the right solution, but this is what I cam up
    > >>> with.
    > >> For what problem?

    > > It takes ~5 secs to load the page. A wait.... thing

    > I daresay you are trying (and failing) to cure the symptoms here. Why is
    > your document this large that it takes ~5 seconds to load? Do you think
    > *adding* a wait image will actually *reduce* download/rendering time?


    Fortunately yes. I am looking for another solution, but so far this is
    the fastest we have.
    Secondly, it is for in-house only.

    > >>> then, when loaded, it should set the height to 0, or something.
    > >> Why?

    > > No waiting anymore...
    > > Or, I could "remove" then waiting img.

    > Good idea :)


    **** Just how do I free an image....?

    > >>> the script (again tested with an alert) is excuted _before_ the table
    > >>> is loaded.
    > >> Unlikely. It may be executed before the table is fully rendered.

    > > Took a closer look. Also at the watch. Found out it is friday evening
    > > and I need a beer.
    > > Also found, that it was at the end of the wrong table ;-)
    > > Realised, that I really need that beer.

    > Cheers :)


    Thanks

    Sonnich
     
    Sonnich Jensen, Aug 27, 2007
    #5
  6. Sonnich Jensen wrote:
    > [...] Thomas 'PointedEars' Lahn [...] wrote:
    >> SonnichJensen wrote:
    >>> [...] Thomas 'PointedEars' Lahn [...] wrote:
    >>>> SonnichJensen wrote:
    >>>>> Not sure whether it is the right solution, but this is what I cam up
    >>>>> with.
    >>>> For what problem?
    >>> It takes ~5 secs to load the page. A wait.... thing

    >> I daresay you are trying (and failing) to cure the symptoms here. Why is
    >> your document this large that it takes ~5 seconds to load? Do you think
    >> *adding* a wait image will actually *reduce* download/rendering time?

    >
    > Fortunately yes. I am looking for another solution, but so far this is
    > the fastest we have.


    Adding data will never reduce download time.

    > Secondly, it is for in-house only.


    Still it is obviously too much.

    >>>>> then, when loaded, it should set the height to 0, or something.
    >>>> Why?
    >>> No waiting anymore...
    >>> Or, I could "remove" then waiting img.

    >> Good idea :)

    >
    > **** Just how do I free an image....?


    I meant you should simply remove the wait image from your code, thereby
    eliminating that part of the problem.

    However, DOM Level 2 Core support provided, you can remove the element from
    the document tree afterwards:

    <body
    onload="var o = document.images["wait"]; o.parentNode.removeChild(o);">
    ...
    <script type="text/javascript">
    document.write(
    '<img src="wait.jpg" alt="Please stand by" name="wait">');
    </script>
    ...
    </body>

    I recommend against that, though.


    HTH

    PointedEars
    --
    realism: HTML 4.01 Strict
    evangelism: XHTML 1.0 Strict
    madness: XHTML 1.1 as application/xhtml+xml
    -- Bjoern Hoehrmann
     
    Thomas 'PointedEars' Lahn, Aug 27, 2007
    #6
  7. Sonnich Jensen

    jodleren Guest

    On Aug 27, 3:59 pm, Thomas 'PointedEars' Lahn <>
    wrote:
    > SonnichJensen wrote:
    > > [...] Thomas 'PointedEars' Lahn [...] wrote:
    > >> SonnichJensen wrote:
    > >>> [...] Thomas 'PointedEars' Lahn [...] wrote:
    > >>>> SonnichJensen wrote:
    > >>>>> Not sure whether it is the right solution, but this is what I cam up
    > >>>>> with.
    > >>>> For what problem?
    > >>> It takes ~5 secs to load the page. A wait.... thing
    > >> I daresay you are trying (and failing) to cure the symptoms here. Why is
    > >> your document this large that it takes ~5 seconds to load? Do you think
    > >> *adding* a wait image will actually *reduce* download/rendering time?

    >
    > > Fortunately yes. I am looking for another solution, but so far this is
    > > the fastest we have.

    >
    > Adding data will never reduce download time.


    I agree. Just to clear things up, it takes 5 seconds to generate the
    page. Certain checks (currently reading 91 directories and no I did
    not come up with that idea).
    The thing I could use, would be a way to ask for files as ABC*.ggg, a
    wildcard. With PHP I have to read the entire directory in.

    BR
    Sonnich
     
    jodleren, Aug 27, 2007
    #7
    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. Lin
    Replies:
    0
    Views:
    1,931
  2. Replies:
    3
    Views:
    578
  3. Sunny Mohan
    Replies:
    0
    Views:
    226
    Sunny Mohan
    Apr 5, 2004
  4. Colin Colin
    Replies:
    2
    Views:
    115
    Colin Colin
    Apr 5, 2004
  5. Janooo
    Replies:
    1
    Views:
    103
Loading...

Share This Page