Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Nov 2009
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    change layout toggle button

    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
    Code:
    <input type="button" value="change layout" onclick="toggle()" />
    JavaScript
    Code:
    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; } }

  • #2
    Regular Coder godofreality's Avatar
    Join Date
    Jan 2009
    Posts
    234
    Thanks
    1
    Thanked 15 Times in 15 Posts
    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
    Code:
    var css = document.getElementsByTagName('link');
    css[0].href = flag+".css";
    woot found the avatar options...i swear they didn't exist b4


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •