JS functions list in body tag


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: JS functions list in body tag

  1. #1
    JS Beginner Guest

    JS functions list in body tag


    Does someone know if it is possible to call more than one onload functions
    in the body tag of a web page. I am wanting to place two slideshows on one
    page, and currently have: <body onload="functionname()" . . . . . .> How
    would I code more that one function? Is it possible, and if so, are they
    separated by some character eg. a semicolon as in: <body onload="functionname();functionname2()"
    . . . . . .>
    Thanks for the help

  2. #2
    Russell Jones Guest

    Re: JS functions list in body tag

    Just call the second function from inside the first one.

    "JS Beginner" <psutton@papcs.com> wrote in message
    news:3c519445$1@10.1.10.29...
    >
    > Does someone know if it is possible to call more than one onload functions
    > in the body tag of a web page. I am wanting to place two slideshows on one
    > page, and currently have: <body onload="functionname()" . . . . . .> How
    > would I code more that one function? Is it possible, and if so, are they
    > separated by some character eg. a semicolon as in: <body

    onload="functionname();functionname2()"
    > . . . . .>
    > Thanks for the help




  3. #3
    sci-fi / Diego Guest

    Re: JS functions list in body tag



    Hi,

    Yes, and you can do as you say, also. If for any particular reason you canīt
    call the function within the js code, you can write: onLoad="function();
    function()". You can, as far as I know, include more than two invocations,
    but I think you should separate them with semicolons ( and a whitespace.
    You could also include arguments between parenthesis with no problems.


    "JS Beginner" <psutton@papcs.com> wrote:
    >
    >Does someone know if it is possible to call more than one onload functions
    >in the body tag of a web page. I am wanting to place two slideshows on one
    >page, and currently have: <body onload="functionname()" . . . . . .> How
    >would I code more that one function? Is it possible, and if so, are they
    >separated by some character eg. a semicolon as in: <body onload="functionname();functionname2()"
    >. . . . . .>
    >Thanks for the help



  4. #4
    patch Guest

    Re: JS functions list in body tag

    What I normally do in these cases I write a function which calls the other
    two and then call this firstone from onload.
    this gives you a bit more control over what you want the functions to do...

    so for instance:
    var loadDone = false;

    function onLoad(timer){
    function1();
    setTimeout('function2()',timer)
    loadDone = true;
    }

    then:
    <body onload="onLoad(1000)">

    have fun

    patch


    JS Beginner wrote in message <3c519445$1@10.1.10.29>...
    >
    >Does someone know if it is possible to call more than one onload functions

    [...snip...]
    nctionname();functionname2()"
    > . . . . .>
    >Thanks for the help




  5. #5
    Josh Guest

    Re: JS functions list in body tag


    "sci-fi / Diego" <diego@barcia.org> wrote:
    >
    >
    >Hi,
    >
    >Yes, and you can do as you say, also. If for any particular reason you canīt
    >call the function within the js code, you can write: onLoad="function();
    >function()". You can, as far as I know, include more than two invocations,
    >but I think you should separate them with semicolons ( and a whitespace.
    >You could also include arguments between parenthesis with no problems.
    >
    >
    >"JS Beginner" <psutton@papcs.com> wrote:
    >>
    >>Does someone know if it is possible to call more than one onload functions
    >>in the body tag of a web page. I am wanting to place two slideshows on

    one
    >>page, and currently have: <body onload="functionname()" . . . . . .> How
    >>would I code more that one function? Is it possible, and if so, are they
    >>separated by some character eg. a semicolon as in: <body onload="functionname();functionname2()"
    >>. . . . . .>
    >>Thanks for the help

    >


    Probably a better way would be to do this:
    <script>
    function setup()
    {
    function1();
    function2();
    }
    </script>

    <body onload="setup()">
    ...
    </body>

    Then you can setup global variants and other setup stuff all in one place.

    -Josh

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center