vendredi 14 septembre 2018

Setting HTML tag attribute before load

I use cookies to remember a preference for the user. Basically, I have a left hand panel that can be collapsed or expanded using a button. When the user clicks it, I remember its state through the cookie.

Now I need to keep the initial load of the page in sync with what the cookie says, to prevent it from jerky behavior.

That is the class in <body class="mini-navbar">. This class either is there or not depending on the state.

I have all the methods to get and set a cookie.

What I need is how can I add/remove this class dynamically before the page is loaded based on the cookie?

Can someone please help?

Thank you.




Aucun commentaire:

Enregistrer un commentaire