NameSilo

[Resolved] Changing color scheme

SpaceshipSpaceship
Namecheap AuctionsNamecheap Auctions
Namecheap AuctionsNamecheap Auctions
Watch

John84

Established Member
Impact
2
Changing color scheme

Im using the following code to change the color scheme of a website...

<img src="images/bg_green_box.gif" alt="" onclick="document.getElementById('bg_css').href='bg_green.css'" />
<img src="images/bg_blue_box.gif" alt="" onclick="document.getElementById('bg_css').href='bg_blue.css'" />
<img src="images/bg_peach_box.gif" alt="" onclick="document.getElementById('bg_css').href='bg_peach.css'" />


...with this between the head tags...

<link id="bg_css" rel="stylesheet" href="bg_green.css" type="text/css" />


... problem is the default color scheme, bg_green.css, will be loaded again once the user clicks on another page of the website. Is there a way for the site to remember which scheme was chosen as the user navigates through the site?
 
0
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
I think that can be done through cookies.

I cannot see any other better explanation for the site to remember the preferences of the user even if he or she visits it after some days.
 
0
Close
Problem Solved. Used the following...

Code:
<script type="text/javascript">
//<![CDATA[

window.onload = function(){
    if(document.cookie.match(/UseCss=(\w+)/) != null){
        document.getElementById('bg_css').href = 'bg'+RegExp.$1+'.css';
    }
    else{
        document.getElementById('bg_css').href = 'bg_green.css';
    }
}

function ChangeCss(toWhich){
    document.cookie = 'UseCss='+toWhich+';';
    document.getElementById('bg_css').href = 'bg'+toWhich+'.css';
}

//]]>
</script>
 
0
Close
DomainEasy: flexible LTO options. Close more domain deals with financing.

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Filters for activity feeds
Your news feed, Latest activity, and the activity tab on profiles now have filter buttons: All, Posts, Quick replies, and Other. Your...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back