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 2 of 2
  1. #1
    Regular Coder howie2009's Avatar
    Join Date
    May 2009
    Location
    Ireland
    Posts
    206
    Thanks
    37
    Thanked 0 Times in 0 Posts

    Great window.onload=init; workaround

    Use:
    Code:
    function addLoadEvent(func)
    {    
        var oldonload = window.onload;
        if (typeof window.onload != 'function')
        {
            window.onload = func;
        } 
        else 
        {
            window.onload = function()
            {
                oldonload();
                func();
            }
        }
    }
    
    addLoadEvent(init);

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    That is an okay solution, a better one would be something like this: http://ejohn.org/blog/flexible-javascript-events/

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]


  •  

    Posting Permissions

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