tags:

views:

22

answers:

2

I was wondering if it was possible to have one element only loaded once upon visiting my website.

In other words, I have a <div> which contains a bunch of different spritely backgrounds, and I was wondering if I could only have that single <div> load once, and then, each time an end-user loads a different page, that <div> stays the same.

The effect I would like to achieve is to not have the animation start over.

How hard is this to implement, and how exactly do I do this? Is this too much of a hassle to quickly implement? Also, I believe this has something to do with Ajax, is that right?

Thanks!

+1  A: 

Also, I believe this has something to do with Ajax, is that right?

You can update your entire site except your div "with ajax", i.e. without refreshing the page. This implies, that your website must be a kind of javascript application. If it isn't already, you'll need to rewrite some (or more) parts.

The MYYN
Thanks for the info, I like Gus' idea better, just because it's a little more compatible with what I have right now, and takes no rewriting.
BOSS
+1  A: 

A more simple solution may be to use your server side code to determine if the page request is the first, or a subsequent request, and show a static background for these subsequent requests.

This can be done in a few lines in most server-side languages. Which are you using?

Gus
Cool, that sounds great! I'm using ASP and ASP.NET actually
BOSS
I would suggest using a session variable to store when a user first visits the site. I don't know ASP all that well, but it looks like you can just set<% Session("seen-animation") = True %>and before this, check for this being set and either display the animation or the static image.
Gus
Well, what I mean is, I want the animation to be left off from the end-user's previous page. Say, you navigate the first page long enough to see the underground animation, and then you navigate to the "Shop!" page, I would like for the animation to continue from where it had left off.
BOSS
Can you tell your animation to start at different points, from within the HTML? If so, you could get a rough idea of how long the animation has been playing for by storing the date and time the animation was started in a session variable. Then you could check the time difference on the second request and serve the relevant part of the animation. If starting the animation halfway through is not a go, then it would have to be Ajax I think.
Gus