I'm new to Javascript and web programming in general, so this may be a silly mistake. Nevertheless, I've had problems finding information about it.
I am developing a game in Javascript, where the player can walk around and move from scene to scene by clicking and having their avatar walk to different buildings/objects. For now, I just have the page change location, by calling this.gotoTimer = setTimeout(self.location = this.targetURL, 1000);
if a collision is detected.
The page links fine in both browsers. The problem is when the user presses the back button...In Chrome, everything resets; The player spawns in the same area as I have it set up in code, and all of the 'linktargets' are still valid. This is the desired behavior.
In Firefox, once the back button is pressed and the page reloads, the player is at his/her last known position, and the linktarget they visited will no longer link...I can eventually deactivate all of them by visiting them and pressing the back button.
From what I've been able to research, it seems to be a problem with how Firefox treats the cache, and the workaround I've been able to find involves appending a random number or the time to the Javascript files. This strikes me as gross. I may also be way off.
So I'm wondering two things:
- Is this an accurate assumption of the problem, or is there another issue?
- If it is, what is the best way to append these numbers. The entire concept seems very hacky to me...