OnLoad events on elements other than BODY ?

M

maria.iglesias.19

Hya,

Is it possible to have onload events on elements other than the body
tag ?

Thanks in advance,
Maria
 
E

Evertjan.

wrote on 27 jun 2007 in comp.lang.javascript:
Is it possible to have onload events on elements other than the body
tag ?

<img
src = '...jpg'
onload = 'alert(this.src+ " is found");'
onerror = 'alert(this.src+ " is NOT found");'
 
M

maria.iglesias.19

wrote on 27 jun 2007 in comp.lang.javascript:


<img
src = '...jpg'
onload = 'alert(this.src+ " is found");'
onerror = 'alert(this.src+ " is NOT found");'

Does this only work for image elements?
I tried it on a div element and nothing :(
 
E

Evertjan.

wrote on 27 jun 2007 in comp.lang.javascript:

[please do not quote signatures, a good newsreader will skip them for you]
Does this only work for image elements?

That was not your first Q, that needed only 1 affirmative example.
I tried it on a div element and nothing :(

What would be the logic or the use?

It is not the loading of an element that is flagged,
but the loading of external data by that element.
And <div> has none.
 
M

maria.iglesias.19

wrote on 27 jun 2007 in comp.lang.javascript:

[please do not quote signatures, a good newsreader will skip them for you]
Does this only work for image elements?

That was not your first Q, that needed only 1 affirmative example.
I tried it on a div element and nothing :(

What would be the logic or the use?

It is not the loading of an element that is flagged,
but the loading of external data by that element.
And <div> has none.

what's a newsreader? what's a good newsreader? (I am using the google
groups webpage.)

regarding the topic;
I am trying to call a method which calls a number of further methods
upon some event. At the moment I have a <script> ... </script> inside
my html code which calls this function. So I am trying to remove the
script from the html and place it somewhere more appropriate.
 
E

Evertjan.

wrote on 28 jun 2007 in comp.lang.javascript:
wrote on 27 jun 2007 in comp.lang.javascript:
On Jun 27, 7:17 pm, "Evertjan." <[email protected]>
wrote:
wrote on 27 jun 2007 in comp.lang.javascript:
Is it possible to have onload events on elements other than the
body tag ?
<img
src = '...jpg'
onload = 'alert(this.src+ " is found");'
onerror = 'alert(this.src+ " is NOT found");'

[please do not quote signatures, a good newsreader will skip them for
you]
what's a newsreader? what's a good newsreader? (I am using the google
groups webpage.)

[interquoting corrected]

Some Googling about "usenet" will tell you.


Do you agree with that?
regarding the topic;
I am trying to call a method which calls a number of further methods
upon some event.

"method"?

Do you mean a javascript function with "method"?
Is that all clientside code?
At the moment I have a <script> ... </script> inside
my html code which calls this function. So I am trying to remove the
script from the html and place it somewhere more appropriate.

How can serverside javascript be placed more apropriate
than in the html code?

The linking to a js file like this

<script type='text/javascript' src='xxx.js'></script>

is not necessarily "better/more apropriate",
unless you want to reuse a large chunk of code in different htmls
and want to minimize download time with slow connections.
It even has some caching drawbacks.
 
L

Lee

(e-mail address removed) said:
wrote on 27 jun 2007 in comp.lang.javascript:
wrote on 27 jun 2007 in comp.lang.javascript:
Is it possible to have onload events on elements other than the body
tag ?
<img
src = '...jpg'
onload = 'alert(this.src+ " is found");'
onerror = 'alert(this.src+ " is NOT found");'

[please do not quote signatures, a good newsreader will skip them for you]
Does this only work for image elements?

That was not your first Q, that needed only 1 affirmative example.
I tried it on a div element and nothing :(

What would be the logic or the use?

It is not the loading of an element that is flagged,
but the loading of external data by that element.
And <div> has none.

what's a newsreader? what's a good newsreader? (I am using the google
groups webpage.)

regarding the topic;
I am trying to call a method which calls a number of further methods
upon some event. At the moment I have a <script> ... </script> inside
my html code which calls this function. So I am trying to remove the
script from the html and place it somewhere more appropriate.

It sounds like your best option is to use the body's onload handler.


--
 

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

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top