Javascript and when it is executed...

S

Sonnich Jensen

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
 
T

Thomas 'PointedEars' Lahn

Sonnich said:
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
 
S

Sonnich Jensen

For what problem?

It takes ~5 secs to load the page. A wait.... thing
The required `alt' attribute is missing. http://validator.w3.org/ Added.

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.
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.


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


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

:)
Then they did not make it the way I want it to :-]
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
 
T

Thomas 'PointedEars' Lahn

Sonnich said:
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?
No waiting anymore...
Or, I could "remove" then waiting img.

Good idea :)
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
 
S

Sonnich Jensen

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.
Good idea :)

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

Thanks

Sonnich
 
T

Thomas 'PointedEars' Lahn

Sonnich said:
SonnichJensen said:
[...] 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.
**** 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
 
J

jodleren

SonnichJensen said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top