Results 1 to 2 of 2

Thread: Can Styleswitch.js be changed to always return to default style.

  1. #1
    Join Date
    Feb 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Can Styleswitch.js be changed to always return to default style.

    Is there a way to change Styleswitch.js so that a refresh returns the user back to the default state?
    Currently, the last choice selected remains when returning to the page. Even an F5 refresh does not revert back to the default.
    This may be desirable for some, but for the design I am working on, I would rather have it always default back to the original style.
    Would this be possible. This is what I have coded in currently:

    Code:
    <link rel="stylesheet" type="text/css" href="css/drs-style_default.css" />
    <link rel="alternate stylesheet" type="text/css" media="screen" title="white-theme" href="css/drs-style_white-non-serif.css" />
    <link rel="alternate stylesheet" type="text/css" media="screen" title="white-theme-serif" href="css/drs-style_white-serif.css" />
    <link rel="alternate stylesheet" type="text/css" media="screen" title="black-theme" href="css/drs-style_black-non-serif.css"/>
    <link rel="alternate stylesheet" type="text/css" media="screen" title="black-theme-serif" href="css/drs-style_black-serif.css"/>
    <script src="js/styleswitch.js" type="text/javascript">
    
    /***********************************************
    * Style Sheet Switcher v1.1- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
    * This notice MUST stay intact for legal use
    * Visit Dynamic Drive at http://www.dynamicdrive.com/ for this script and 100s more
    ***********************************************/
    </script>
    </head>
    
    <body>
    <div class="container">
      <div class="row">
        <div class="col-md-12">
          <form id="switchform">
            <select name="switchcontrol" size="1" class="form-control" onChange="chooseStyle(this.options[this.selectedIndex].value, 60)">
              <option value="none" selected="selected">Default style</option>
              <option value="white-theme">White Theme</option>
              <option value="white-theme-serif">White Theme - serif</option>
              <option value="black-theme">Black Theme</option>
              <option value="black-theme-serif">Black Theme - serif</option>
            </select>
          </form>
    		</div>
    	</div>
    Last edited by jscheuer1; 04-09-2014 at 03:54 AM. Reason: Format

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    For (in styleswitch.js):

    Code:
    var manual_or_random="manual" //"manual" or "random"
    leave that as is ("manual"). Also in the same file find:

    Code:
    function chooseStyle(styletitle, days){ //Interface function to switch style sheets plus save "title" attr of selected stylesheet to cookie
    if (document.getElementById){
    setStylesheet(styletitle)
    setCookie("mysheet", styletitle, days)
    }
    }
    Using a text only editor like NotePad, add the highlighted red comment tokens as shown:

    Code:
    function chooseStyle(styletitle, days){ //Interface function to switch style sheets plus save "title" attr of selected stylesheet to cookie
    if (document.getElementById){
    setStylesheet(styletitle)
    //setCookie("mysheet", styletitle, days)
    }
    }
    Save and use that version.

    You will have to clear the current cookie (if any).

    And the browser cache may need to be cleared and/or the page refreshed to see changes.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Similar Threads

  1. Resolved Having Link Style Default to Active Before Being Clicked On
    By Abbster22 in forum JavaScript
    Replies: 0
    Last Post: 10-22-2010, 03:08 AM
  2. Return to the default state of menu problem
    By asimcan in forum JavaScript
    Replies: 2
    Last Post: 07-08-2009, 12:15 PM
  3. Changing style of default Window
    By Sachin20082008 in forum Dynamic Drive scripts help
    Replies: 2
    Last Post: 10-14-2008, 01:11 PM
  4. Styleswitch display link(s) depending on which style is saved in cookie?
    By dsontag in forum Dynamic Drive scripts help
    Replies: 1
    Last Post: 12-22-2007, 10:17 AM
  5. Replies: 3
    Last Post: 10-26-2007, 10:10 AM

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
  •