Style a page upon leaving that page?

Is there a way to apply styles to an element upon or just before leaving that page and going to a different page?
For example, I have a fading out CSS3 Animation and I want to apply that right before a user leaves the current page to go to a different page in my site or to another page / site all together.

I appreciate and welcome all and any help or comments regarding this.

You’d need JS to do that, but it sounds like it might be pretty annoying, as you’d have to prevent the user from leaving the page for a while, which would probably make me never want to visit your site again, TBH.

Yes, you’re right. Now that I’ve had some time to think about it, I don’t think that is a good user-experience at all. Thank you for helping me realise this / that !

IE had these in place since IE4 I believe (removed in IE9 fortunately) and came as standard in front-page and was the curse of many a webpage :slight_smile:

yeah, i’m really glad @ralph_m bought me to my senses. I was really fascinated and obsessed with CSS3 Animations and wanted to do a fade-out upon leave, but when I realised that would prevent the user form reaching his / her goal ( in this case navigating to another page or leaving my site entirely ) I understood it was wrong of me to try to implement it and it would only make my visitors want to leave my site more. :lol: