Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var sheets = document.querySelectorAll('[rel="alternate stylesheet"]');
- window.onload = function(e){
- for(var i=0; i<sheets.length; i++){
- if(document.cookie.split(";")[0].split("=")[1] == sheets[i].title){
- sheets[i].disabled = false;
- }
- else{
- sheets[i].disabled = true;
- }
- }
- }
- function changeStyle(obj){
- for(var i=0; i<sheets.length; i++){
- if(sheets[i].title == obj){
- sheets[i].disabled = false;
- document.cookie = "title="+sheets[i].title+";";
- }
- else{
- sheets[i].disabled = true;
- }
- }
- }
- var container = document.getElementById("stylesheets");
- var ul= document.createElement("ul");
- for (var i=0; i<sheets.length; i++){
- var li = document.createElement("li");
- var a = document.createElement("a");
- a.title = sheets[i].title;
- a.innerHTML = sheets[i].title;
- a.href="#";
- a.setAttribute('onclick', "changeStyle(this.title); event.preventDefault();");
- li.appendChild(a);
- ul.appendChild(li);
- }
- container.appendChild(ul);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement