Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Javascript (http://www.velocityreviews.com/forums/f68-javascript.html)
-   -   Javascript and when it is executed... (http://www.velocityreviews.com/forums/t932580-javascript-and-when-it-is-executed.html)

Sonnich Jensen 08-24-2007 01:08 PM

Javascript and when it is executed...
 
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


Thomas 'PointedEars' Lahn 08-24-2007 01:19 PM

Re: Javascript and when it is executed...
 
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_not...ml#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

Sonnich Jensen 08-24-2007 01:39 PM

Re: Javascript and when it is executed...
 
On Aug 24, 4:19 pm, Thomas 'PointedEars' Lahn <PointedE...@web.de>
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_not...ml#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


Thomas 'PointedEars' Lahn 08-24-2007 01:45 PM

Re: Javascript and when it is executed...
 
Sonnich Jensen wrote:
> On Aug 24, 4:19 pm, Thomas 'PointedEars' Lahn <PointedE...@web.de>
> 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$8300dec7@news.demon.co.uk>

Sonnich Jensen 08-27-2007 12:14 PM

Re: Javascript and when it is executed...
 
On Aug 24, 4:45 pm, Thomas 'PointedEars' Lahn <PointedE...@web.de>
wrote:
> SonnichJensen wrote:
> > On Aug 24, 4:19 pm, Thomas 'PointedEars' Lahn <PointedE...@web.de>
> > 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


Thomas 'PointedEars' Lahn 08-27-2007 12:59 PM

Re: Javascript and when it is executed...
 
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

jodleren 08-27-2007 07:13 PM

Re: Javascript and when it is executed...
 
On Aug 27, 3:59 pm, Thomas 'PointedEars' Lahn <PointedE...@web.de>
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



All times are GMT. The time now is 05:44 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.