Results 1 to 3 of 3

Thread: Style Sheet Switcher - 1 link for both

  1. #1
    Join Date
    Nov 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Style Sheet Switcher - 1 link for both

    Hi

    I'm using the Style Sheet Switcher and would like to have just 1 button that can switch between the 2 CSS files I have.

    Currently i'm using:

    <a href="javascript:chooseStyle('orange', 60)">Orange</a>
    <a href="javascript:chooseStyle('grey', 60)">Grey</a>

    ..but would like one link that switches between them. Is this possible?

    Thanks

  2. #2
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Warning: Please include a link to the DD script in question in your post. See this thread for the proper posting format when asking a question.

    This is untested yet but should work. Try this code:

    Code:
    <script type="text/javascript">
    
    function chooseStyleAlt(days){
    if (document.getElementById){
    var selectedtitle=getCookie("mysheet")
    if (selectedtitle=="orange")
    chooseStyle('grey', days)
    else
    chooseStyle('orange', days)
    }
    }
    
    </script>
    
    <a href="javascript:chooseStyleAlt(60)">Switch between Gray and Orange style</a>

  3. #3
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Just for the record, it would be possible to switch the name of the link each time it was clicked, but that would be a lot harder. Using the above code should do fine.... just make the link called something generic.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

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