Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

switch

Status
Not open for further replies.

matt2112

Programmer
Joined
Jan 22, 2006
Messages
1
Location
GB
Hi guys,

I have my website setup with a rather cool .css switcher, it allows visitors to use 2 themes, black and white.

Here is the problem, to change a .css I use

<a href="#" onclick="setActiveStyleSheet('light'); return false;">light</a>

However, what im trying to end up with is a link that will in the same fashion as a button..

ie clicking

<a href="#" onclick="somefunction(); return false;">switch</a>

will switch to the black .css sheet, and clicking it again, will switch to the white .css

I have no idea, hope i explained myself well enough...
 
Try something like this:
Code:
function setActiveStyleSheet()
{
var body = document.getElementsByTag('body');
if (body.className == 'class1')
  {
   body.className = 'class2';
  }
else
  {
  body.className = 'class1';
  }

}

<a href="#" onclick="setActiveStyleSheet(); return false;">light</a>
Lee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top