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 3 of 3

Thread: document.onload

  1. #1
    New Coder
    Join Date
    Mar 2003
    Posts
    73
    Thanks
    0
    Thanked 0 Times in 0 Posts

    document.onload

    I set up the following snippett:

    <script>
    function PageLoaded()
    {
    alert("test");
    }
    document.onload = PageLoaded;
    </script>


    Unfortunately, the alert is not being called. What am I doing wrong?

    Additionally, if onload() is defined in the body tag, is there a way to add a call to what is already being called?
    Brad Eck
    www.sitesdynamic.com

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Posts
    338
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I believe it's window.onload and not document.onload.

    Hope that helps!

    Happy coding!

  • #3
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    if onload() is defined in the body tag,
    actualy in body you can call (fire, if you want...), a function, not to define. and onload is an event handler, not a function onload(), if you use it that way:

    <body onload="aFunction()">

    is similar with

    <script>
    function aFunction(){
    '
    '
    '
    }
    window.onload = aFunction;
    </script>
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


  •  

    Posting Permissions

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