Apply temporary css stylesheet on all pages using php javascript -


i have create website disable users, can change page contrast css 1 user selects different colour, far have javascript so, when click on page, in page reloads/refresh css style goes default one. understand there must way save cookie, new php , javascript:

here html:

<body runat="server" id="body" style="zoom: 100%"> <div id="container">      <div id="highvis">            <ul>         <li class="highviss"> <a href="#" onclick="swapstylesheet('css/webcss2.css');return false;">high vis</a>         <li> <a href="#" onclick="swapstylesheet('css/webcss3.css');return false;">dark</a>         <li> <a href="#" onclick="swapstylesheet('css/webcss.css');return false;">default</a>          <li><a href="#" onclick="zoomin();return false;">zoom in ++</a></li>         <li><a href="#" onclick="zoomout();return false;">zoom out -</a></li>                    </ul>         </div>   

here javascript:

function swapstylesheet(sheet) {         document.getelementbyid('pagestyle').setattribute('href', sheet);  }   function zoomin() { var page = document.getelementbyid('body'); var zoom = parseint(page.style.zoom) + 10 +'%' page.style.zoom = zoom; return false; }  function zoomout() { var page = document.getelementbyid('body'); var zoom = parseint(page.style.zoom) - 10 +'%' page.style.zoom = zoom; return false; } 

can please me this, if not ideas, or how can go it.

this js solution similar yours remembers . on swap stylesheet want make cookie stylesheet name:

function swapstylesheet(sheet) {     createcookie('sheet2load',sheet,365);//save sheet name in cookie     document.getelementbyid('pagestyle').setattribute('href', sheet); } 

and load style sheet on refresh , somewhere (if using jquery in .ready event , on pure js somwhere bottom of body in script tag) need :

var s=readcookie('sheet2load') if(s!==null)document.getelementbyid('pagestyle').setattribute('href', s); 

we need these 2 functions i've borrowed http://www.quirksmode.org/js/cookies.html

function createcookie(name,value,days) { if (days) {     var date = new date();     date.settime(date.gettime()+(days*24*60*60*1000));     var expires = "; expires="+date.togmtstring(); } else var expires = ""; document.cookie = name+"="+value+expires+"; path=/"; } function readcookie(name) { var nameeq = name + "="; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) {     var c = ca[i];     while (c.charat(0)==' ') c = c.substring(1,c.length);     if (c.indexof(nameeq) == 0) return c.substring(nameeq.length,c.length); } return null; } 

this should , although code untested if didn't work post comment , i'll check , either way should give hints on how it


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

c# - Unity IoC Lifetime per HttpRequest for UserStore -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -