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 1 of 1
  1. #1
    Regular Coder
    Join Date
    Jul 2011
    Location
    India
    Posts
    496
    Thanks
    3
    Thanked 57 Times in 56 Posts

    Function is not working on page refresh in firefox 14

    Hi,

    Following function is working fine when we load page 1st time, but not working when we refresh the page in Firefox (but working fine in Chrome)

    Code:
    function start() {
            getXY();
            rndmX = x, rndmY = y;
            snake.Body.unshift([rndmX,rndmY]);
            resetInterval();            
            direction = snake.dir[Math.round(Math.random()*3)];
            getFood();        
            enable('#restart');
            $('#restart').css({background:'#9B3378'});
            enable('#pause');
            $('#pause').css({background:'#E09926'});
            enable('#stop');
            $('#stop').css({background:'#AD4343'});
            cnvs.focus();
            disable('#start');
            $('#score').html(score);
        }
    Following are the functions being called in above functions:

    Code:
    function getRN(max) {
            var n, mod;
            n = Math.round(Math.random()*max);
            mod = n%grid;
            n = n - mod;
            n = n >max?max:n;
            return n;        
        }
        
        function getXY() {
            x = getRN(maxX);
            y = getRN(maxY);
            return x,y;
        }
    
    function resetInterval() {
            clearInterval(interval);
            interval = 0
            interval = setInterval(moveSnake, snake.speed);
        }
    Please help ... Thank you in advance
    Last edited by vikram1vicky; 08-28-2012 at 01:19 PM. Reason: wrong title


 

Tags for this Thread

Posting Permissions

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