WordPress.org

Support

Support » Plugins and Hacks » Combining multiple hacks that use onload

Combining multiple hacks that use onload

  • 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

Viewing 3 replies - 1 through 3 (of 3 total)
  • You can also go
    window.onload = function ()
    {
    extractBlockquoteCitations();
    makeNiceTitles();
    externalLinks();
    }

    ~Mary

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

    Great solution!!
    Exactly what we need.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Combining multiple hacks that use onload’ is closed to new replies.
Skip to toolbar