OnLoad events on elements other than BODY ?

Discussion in 'Javascript' started by maria.iglesias.19@googlemail.com, Jun 27, 2007.

  1. Guest

    Hya,

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

    Thanks in advance,
    Maria
     
    , Jun 27, 2007
    #1
    1. Advertising

  2. Evertjan. Guest

    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");'
    >



    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Jun 27, 2007
    #2
    1. Advertising

  3. Guest

    On Jun 27, 7:17 pm, "Evertjan." <> 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");'
    >
    >
    >
    > --
    > Evertjan.
    > The Netherlands.
    > (Please change the x'es to dots in my emailaddress)


    Does this only work for image elements?
    I tried it on a div element and nothing :(
     
    , Jun 27, 2007
    #3
  4. Evertjan. Guest

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

    > On Jun 27, 7:17 pm, "Evertjan." <> 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]

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

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Jun 27, 2007
    #4
  5. Guest

    On Jun 27, 8:59 pm, "Evertjan." <> wrote:
    > wrote on 27 jun 2007 in comp.lang.javascript:
    >
    > > On Jun 27, 7:17 pm, "Evertjan." <> 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]
    >
    > > 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.
     
    , Jun 28, 2007
    #5
  6. Evertjan. Guest

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

    > On Jun 27, 8:59 pm, "Evertjan." <> wrote:
    >> wrote on 27 jun 2007 in comp.lang.javascript:
    >>
    >> > On Jun 27, 7:17 pm, "Evertjan." <>
    >> > 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.

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


    Could you answer that re <div>?

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


    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.

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Jun 28, 2007
    #6
  7. Lee Guest

    said:
    >
    >On Jun 27, 8:59 pm, "Evertjan." <> wrote:
    >> wrote on 27 jun 2007 in comp.lang.javascript:
    >>
    >> > On Jun 27, 7:17 pm, "Evertjan." <> 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]
    >>
    >> > 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.


    --
     
    Lee, Jun 28, 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. Daves
    Replies:
    1
    Views:
    1,378
    Brock Allen
    Mar 15, 2005
  2. Fabio R.
    Replies:
    0
    Views:
    802
    Fabio R.
    Mar 25, 2005
  3. Andy Fish
    Replies:
    0
    Views:
    336
    Andy Fish
    Apr 12, 2006
  4. Chris
    Replies:
    2
    Views:
    457
    Beauregard T. Shagnasty
    Nov 26, 2007
  5. David Otton

    window.onload and body.onload differences

    David Otton, Nov 4, 2004, in forum: Javascript
    Replies:
    2
    Views:
    558
    Martin Honnen
    Nov 4, 2004
Loading...

Share This Page