Rhobur Posted October 26, 2011 Share Posted October 26, 2011 Hi, I need to use an onload statement in my body tag to load a js fuction but couldn't find a solution, my body tag looks like this "<body {if $page_name}id="{$page_name|escape:'htmlall':'UTF-8'}"{/if}>"; problem is that if I add "onload="rankingsPush();" ; right after body, the site isn't loading anymore with a HTTP 500 error and if I add it after the if statement it has no effect. The function rankingsPush() is enclosed in {literal} right after ganalytics code in ganalytics module's header.tpl and the body tag is that in my theme's header.tpl. What am I doing wrong ? TIA Robert Link to comment Share on other sites More sharing options...
phrasespot Posted October 27, 2011 Share Posted October 27, 2011 I need to use an onload statement in my body tag to load a js fuction <body onload="rankingsPush();" {if $page_name}id="{$page_name|escape:'htmlall':'UTF-8'}"{/if}> Should not cause a 500 error, the problem may be somewhere else <body {if $page_name}id="{$page_name|escape:'htmlall':'UTF-8'}"{/if} onload="rankingsPush();"> (or the previous variation) may have no effect if by the time body element is loaded the script required is not loaded Do not use an onload statement, the page already loads jQuery so use a structure as below within the head element, after jQuery load call $(document).ready(function(){ rankingsPush(); }); or simply $(function(){ rankingsPush(); }); Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now