P
P
partyzanx2017-05-25 02:57:42
css
partyzanx, 2017-05-25 02:57:42

How to change the design of a site with remembering cookies?

I have the following code
Written in css: Written in html on each page before the opening < body > tag (that's where you need it before the body tag):
.eco {display: none;}

<div class="eco"><style>.head2 {display: none;} [и так далее]</style></div>

The point is this. I need a button on a site that is in the fiend's settings and it makes the .eco class visible display: initial. And so this div class="eco" gets activated, gives a new design to the site, and is stored in cookies for 40 days.
It would be aerobatics if this button would both activate and deactivate this div class="eco" again when pressed again.
I'm an amateur newbie, so thanks for the specifics in advance!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Stalker_RED, 2017-05-25
@Stalker_RED

Won't work.
1. The tag divcannot be placed before the body.
2. Styles will always be active, regardless of the display value of the wrapper.
3. Just html and css is not enough to solve the problem, you need to fasten js or some kind of server-side language.

P
partyzanx, 2017-05-25
@partyzanx

I found such a solution

<link id="dyncss" rel="stylesheet" type="text/css" href=""> 
 <script type="text/javascript"> 
 function setDynCSS(url) { 
 if (!arguments.length) { 
 url = (url = document.cookie.match(/\bdyncss=([^;]*)/)) && url[1]; 
 if (!url) return ''; 
 } 
 document.getElementById('dyncss').href = url; 
 var d = new Date(); 
 d.setFullYear(d.getFullYear() + 1); 
 document.cookie = ['dyncss=', url, ';expires=', d.toGMTString(), ';path=/;'].join(''); 
 return url; 
 } 
 setDynCSS(); 
 </script>

and html
<img style="cursor:pointer; width: 30px; height:30px;" src="/social/firefox.png" onclick="setDynCSS('/_st/my.css')"> 
<img style="cursor:pointer; width: 30px; height:30px;" src="/social/ie.png" onclick="setDynCSS('/css/new_1.css')">

But I have separate style elements that I would like to work only when the first /_st/my.css is activated.
What needs to be written in the Java script so that when the /_st/my.css button is pressed, these elements work, and when another button is pressed, they turn off?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question