WordPress.org

Ready to get started?Download WordPress

Forums

Combining multiple hacks that use onload (4 posts)

  1. tcervo
    Member
    Posted 10 years ago #

    As some of you may have read in previous topics, trying to combine more than one hack that uses an oload event (either in the body tag as onload="", or in a javascript file with window.onload="") causes only the last one called to actually execute.
    This would cause a problem if, say, you're using the NiceTitles hack to get pretty tooltips, then want to install the Uber Blockquotes hack to make your citations and links appear below your blockquotes...both use window.onload.
    (I wrote up a nice article on my site yesterday, but the servers have been down since 8:00pm last night. I guess their sysadmins all got the holiday off...)
    Anyway, it was unbelievably easy to get around this problem. Simply remove the window.onload event from any script/hack that uses it, inlcuding any onload calls you might have in your body tag. Next, creat the following javascript at the end of your external .js file:
    // Function to allow multiple onload functions to be called
    function multipleOnload()
    {
    extractBlockquoteCitations();
    makeNiceTitles();
    externalLinks();
    }
    window.onload = multipleOnload;
    // end function
    Just put any functions you want to call inside multipleOnload and you're set!
    -Tony

  2. Anonymous
    Unregistered
    Posted 10 years ago #

    You can also go
    window.onload = function ()
    {
    extractBlockquoteCitations();
    makeNiceTitles();
    externalLinks();
    }

    ~Mary

  3. Anonymous
    Unregistered
    Posted 10 years ago #

    couldn't you also simply do,
    <BODY onLoad="extractBlockquoteCitations(); makeNiceTitles(); externalLinks();">
    ?

  4. Anonymous
    Unregistered
    Posted 9 years ago #

    Great solution!!
    Exactly what we need.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.