Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Nov 2002
    Posts
    184
    Thanks
    0
    Thanked 0 Times in 0 Posts

    using 2 onload event in the body tag?

    Want to know is is possible to have 2 diff. onload events in the same page? I have 2 different scripts for 2 diff. things. They both use onload event.....if so, how can we handle it. Thanks.

  • #2
    New Coder
    Join Date
    Jan 2006
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It is for images, but once you use the onload event in the body tag it overrides the image tag onload events. I think//

  • #3
    Master Coder
    Join Date
    Feb 2003
    Location
    Umeå, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    Given there are no other conflicts between the scripts, you simply write them together. If the originals said onload="xxxxx" and onload="yyyyy" respectively, then you can write them together as onload="xxxxx;yyyyy". A better approach would perhaps be to do it in script though.
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #4
    Regular Coder
    Join Date
    Jan 2003
    Posts
    867
    Thanks
    4
    Thanked 8 Times in 8 Posts
    I usually just make a new function and have that call my two other functions.

    <html>
    <head>
    <script>
    function newFunction(){
    xxxx();
    yyyy();
    }
    </script>
    </head>

    <body onload="newFunction();">
    </body>
    </html>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •