Results 1 to 8 of 8

Thread: Style Sheet Switcher (v1.1) based on QueryString Parameter

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

    Default Style Sheet Switcher (v1.1) based on QueryString Parameter

    I am using the stylesheet switcher on dynamic drive . Is there a way to change stylesheets based on a querystring parameter? Basically, if the query string includes "&StyleSheet=BlueStyle" then call and set the BlueStyle.css and cookie on page load.

    Any ideas or help would be much appreciated. Thanks!!

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

    Default

    Sure, try the below modified .js file, which lets you use the URL parameter to set the stylesheet to use on the page via the syntax:

    Code:
    ?StyleSheet=BlueStyle
    where "BlueStyle" should be the "title" attribute value of the linked stylesheet in question, for example:

    Code:
    <link rel="alternate stylesheet" type="text/css" media="screen" title="BlueStyle" href="user.css" />

    Not thoroughly tested, but should work.
    DD Admin

  3. #3
    Join Date
    Apr 2006
    Posts
    30
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Hi ddadmin, thanks, I ran a test and it works well, however I don't see it setting a cookie. Is there a way to do this based on the parameter? Thanks again for your help.

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

    Default

    Inside the modified .js file, try finding the below chunk of code, and add to it the line(s) in red:
    Code:
    if (urlselectstyle){
    setStylesheet(urlselectstyle)
    setCookie("mysheet_r_days", urlselectstyle, 10) 
    }
    The 10 in the above case means 10 days persistence. Again, not fully tested, but should work.
    DD Admin

  5. The Following User Says Thank You to ddadmin For This Useful Post:

    dude9er (11-10-2010)

  6. #5
    Join Date
    Apr 2006
    Posts
    30
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Hi ddadmin, changed the line to and it worked perfectly. Thanks for your help.
    Code:
    setCookie("mysheet", urlselectstyle, 10)

  7. #6
    Join Date
    Mar 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi, have you still got the modified .js file?

    Thanks

  8. #7
    Join Date
    Apr 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi,

    I'd like to use the same js query solution. Is the particular file still available?

    Thank you!

  9. #8
    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

    This should do it:

    styleswitchquery.js
    Last edited by jscheuer1; 04-04-2014 at 02:01 PM. Reason: update script for Safari, add cookie option for url
    - John
    ________________________

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

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
  •