...

View Full Version : change layout toggle button



George Lucas
12-08-2009, 11:19 PM
I'm trying to make a page where you can change a page's layout through 2 separate CSS's via a button. i want to button to change text when it toggles the layouts as well. i have no clue how to do this with an entire CSS file, but here is something i made to change the background. could i use this logic to change the CSS of a page?

HTML
<in
<input type="button" value="change layout" onclick="toggle()" />

JavaScript

var flag = 0; function toggle(){
if(flag==0){
document.getElementById("container").style.backgroundImage="blah.jpg";
flag=1; } else if(flag==1){
document.getElementById("container").style.backgroundImage="blah2.jpg";
flag=0; } }

godofreality
12-09-2009, 03:51 AM
ez enough if u want to swap a whole .css file for another this is all u need just replace the background swapper with this snippet


var css = document.getElementsByTagName('link');
css[0].href = flag+".css";



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum