SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Zealot LunaC's Avatar
    Join Date
    Feb 2001
    Posts
    176
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How would I write 2 onload events into the body tag?

    I currently use
    onLoad="if (self != top) top.location=self.location" and have found a scroller that may work better than my current one but it has an onload command as well.

    I can't seem to figure out how to do both.

    What about if I have 3?

  2. #2
    Say WHA?! goober's Avatar
    Join Date
    Sep 2000
    Location
    United States
    Posts
    1,921
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Write a function in JavaScript and call the function. It should work.

    For help on syntax, refer to the resident JavaScript gurus on the forums, who should pick up on this thread rather quickly.

    Hope this helps.
    Sean Killeen [LinkedIn] [Twitter] [Web]

    Warning: Reality.sys corrupted. Universe halted. Reboot? (Y/N)

  3. #3
    Irritability Defined
    Join Date
    Jul 2000
    Location
    80,000 feet below the surface
    Posts
    1,442
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Writing a new function in JavaScript to call the two onLoads is the hard way.

    The easy way is to call them at the same time by using a colon to separate them.

    e.g.

    <body onLoad="function1();function2();functionxy()" blah blah>
    My 2 Cents (or is that 2.2 Cents including GST?)

  4. #4
    Say WHA?! goober's Avatar
    Join Date
    Sep 2000
    Location
    United States
    Posts
    1,921
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well, you learn something new everyday! That's awesome.

    It will help greatly in the future for me.

    A simple but useful tip! It has my vote for the TechTimes!

    Thanks again BC.
    Sean Killeen [LinkedIn] [Twitter] [Web]

    Warning: Reality.sys corrupted. Universe halted. Reboot? (Y/N)

  5. #5
    SitePoint Zealot LunaC's Avatar
    Join Date
    Feb 2001
    Posts
    176
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, that works great!

    I really appreciate all the help I've received here... there is so-o-o-o-o much to learn

  6. #6
    Irritability Defined
    Join Date
    Jul 2000
    Location
    80,000 feet below the surface
    Posts
    1,442
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not a problem folks! Glad to be of assistance.

    Goober, feel free to send it to Kevin. It's in the TipFeed as well so I'm not sure if Kevin's produced the tip as yet, so check with him.
    My 2 Cents (or is that 2.2 Cents including GST?)

  7. #7
    Say WHA?! goober's Avatar
    Join Date
    Sep 2000
    Location
    United States
    Posts
    1,921
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I certainly will! If it's in the tip feed, it shouldn't be too much longer before I see it come up.
    Sean Killeen [LinkedIn] [Twitter] [Web]

    Warning: Reality.sys corrupted. Universe halted. Reboot? (Y/N)

  8. #8
    JavaScript Guru (Big Ego) Arielladog's Avatar
    Join Date
    Jul 1999
    Location
    SC, USA
    Posts
    390
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey guys,

    Just as another way to do this, although your way is probably much better, but with this way, you don't mess with the <body> tag:

    <script>
    window.onload = new Function("function1();function2();functionxy()");
    </script>

    or:

    window.onload = function{
    function1();
    function2();
    functionxy()
    }

    and, just to clarify, you can't use:

    window.onload=function1;
    window.onload=function2;

    Anyway, just thought I'd add my two cents,
    aDog


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
  •