Detecting Page Refresh

Hi,

I have an animation that reloads everytime as and when the page holding it refreshes. Is there a way I can detect a page refresh ?(either in flash) or thru js ?