AnsweredAssumed Answered

Javascript running everytime i change a page...

Question asked by community-support on Jan 13, 2014
Latest reply on Jan 13, 2014 by community-support
Hi everyone...

I changed my _headerModuleList.tpl in way to have a header displaying time:


The problem is that sometimes (when i change page, but not always) it doesnt run the javascript i added and the time doesn't appear...

my code on _headerModuleList.tpl


global $current_user;

$id = $current_user->id;

$imp_id = $current_user->trabalho_imp_c;

if ($imp_id != '' && $imp_id != NULL) {


$imp = new CONT_Imputacao_Tempos();



     A trabalhar em: {php}echo $imp->accounts_cont_imputacao_tempos_1_name;{/php}

     ênicio: {php}echo $imp->inicio;{/php}


     Finalizar Interven‹o



{/php} [/CODE]

my javascript code:


//Function that calculates the time and stick the header to the top of the page when you scroll down

function timer() {

       // This function will be executed when the user scrolls the page.

    $(window).scroll(function(e) {

        // Get the position of the location where the scroller starts.

        var scroller_anchor = $('.scroller_anchor').offset().top;

        // Check if the user has scrolled and the current position is after the scroller start location and if its not already fixed at the top

        if ($(this).scrollTop() >= scroller_anchor && $('.scroller').css('position') != 'fixed')

        {    // Change the CSS of the scroller to hilight it and fix it at the top of the screen.


                'background': '#C50000',

                'border': '1px solid #000',

                'position': 'fixed',

                'top': '0px',


                'height': '20px',


            // Changing the height of the scroller anchor to that of scroller so that there is no change in the overall height of the page.

            $('.scroller_anchor').css('height', '50px');


        else if ($(this).scrollTop() 60) {

   aux = Math.floor(t/60);

   remaining = t % 60;

   t = aux + 'h '+remaining;


  t +='m';

  return t;


if (window.addEventListener) //DOM method for binding an event

window.addEventListener('load', timer, false);

else if (window.attachEvent) //IE exclusive method for binding an event

window.attachEvent('onload', timer);

else if (document.getElementById) //support older modern browsers



like i said it doesnt run the 'custom/themes/default/javascript/java.js' (sorry for the confusion on the code)

Can anyone help me?

Thank you in advanced,

Spock :cool:

(from SpockPT)