Results 1 to 4 of 4

Thread: Calling two function with body onLoad

  1. #1
    Join Date
    Jan 2007
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Calling two function with body onLoad

    Hello all,

    How can i call two functions with body onLoad event? Suppose i would like to call two ajax functions to load default data with abc() and xyz() functions in my onLoad event of body. I have done simple as calling two functions like this:
    Code:
    onLoad="abc();xyz();"
    Am i wrong? Can anyone tell me?

    With Regards

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Sure. There might be problems if they overlap/relate too much.... if the variable names are the same, etc. In general, though, that shhould be all you need.
    You could also do:

    onLoad="hostfunction();"

    in the script--
    function hostfunction() {
    abc();
    xyz();
    }

    That might be nice if you wanted to run a bunch of functions.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    Or if you really wanted to: (in the head section):

    Code:
    window.onload = abc;xyz
    - Mike

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Code:
    window.onload = abc;xyz
    No, that would break. You probably mean:
    Code:
    window.onload = function() { abc(); xyz(); };
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

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