Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Stylesheet Switcher Browser and Cookie issues

  1. #1
    Join Date
    May 2008
    Posts
    91
    Thanks
    35
    Thanked 0 Times in 0 Posts

    Default Stylesheet Switcher Browser and Cookie issues

    1) Script Title: Style Sheet Switcher (v1.1)

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...etswitcher.htm

    3) Describe problem: I went ahead and set up a simple two page site to test the earlier question on keeping the initial randomly selected stylesheet consistent through out the site. The link is http://www.rspsitedesign.com/Random/ Here is what is weird in Firefox: First I cleared out cache and then disabled all cookies. It starts out with the default style sheet, and toggles back and forth between home and inside page. On about the third toggle it shifts to and alternative stylesheet. So it is not consistent. If cookies are enabled it seems to work ok.
    In Internet Explorer if privacy is set to high, the random selection is inconsistent similar to Firefox. If cookie privacy is set to medium the random selection seems to work ok.
    Is there a way to test for browser privacy levels and if the are allowed then use the random selection. If not, then use the default style sheet?

    There is also a delay in the page transfer which is unusual given the simplicity of the pages.
    Last edited by printman55; 05-30-2010 at 06:48 PM. Reason: Resolved

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

    Default

    The script relies on cookies to store the style settings, so if you disable cookies in the browser, it's to be expected that the styles will no longer be properly recalled.

    Is there a way to test for browser privacy levels and if the are allowed then use the random selection. If not, then use the default style sheet?
    You can try checking whether or not cookies are enabled on the user's browser, and if not, skip the changing of styles by the script. Try the below modified .js file.
    DD Admin

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

    printman55 (05-26-2010)

  4. #3
    Join Date
    May 2008
    Posts
    91
    Thanks
    35
    Thanked 0 Times in 0 Posts

    Default

    Thanks for the code. I uploaded the new styleswitch.js file and with cookies enabled the only stylesheet that applies is the default.css. This ocurrs in both IE and Firefox.
    http://www.rspsitedesign.com/Random/index.html
    In IE there is also an error code as follows:
    Message: 'return' statement outside of function
    Line: 69
    Char: 1
    Code: 0
    URI: http://www.rspsitedesign.com/Random/styleswitch.js

  5. #4
    Join Date
    May 2008
    Posts
    91
    Thanks
    35
    Thanked 0 Times in 0 Posts

    Default

    I reset the two variables in the .js file:
    var manual_or_random="random" //"manual" or "random"
    var randomsetting="sessiononly" //"eachtime", "sessiononly", or "x days (replace x with desired integer)". Only applicable if mode is random.
    Now with cookies enabled or disabled it defaults to default.css in both IE and Firefox.
    Also in IE still getting the line 69 error above.

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

    Default

    Ah yes there is an error in the modified .js file I posted. Try the below version instead.
    DD Admin

  7. #6
    Join Date
    May 2008
    Posts
    91
    Thanks
    35
    Thanked 0 Times in 0 Posts

    Default

    I tried it still no change. I reset the code lines:
    var manual_or_random="random" //"manual" or "random"
    var randomsetting="sessiononly" //"eachtime", "sessiononly", or "x days (replace x with desired integer)". Only applicable if mode is random.
    Plus still getting the line 69 error in IE.

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

    Default

    You shouldn't be getting any errors any more at least (I just tested it again). Do you have a link to the problem page?
    DD Admin

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

    printman55 (05-30-2010)

  10. #8
    Join Date
    May 2008
    Posts
    91
    Thanks
    35
    Thanked 0 Times in 0 Posts

    Default

    Here is the link to the page:
    http://www.rspsitedesign.com/Random/index.html It now appears to be working properly!!!
    Yea!!! Cookies or no cookies works as planed. When cookies disallowed it reverts to the default.css. The error has gone away. I must have made an error in the way the revised js file was uploaded because I did it again and now it works. There is still a little more time delay in the toggling between inside and homepages though.
    Last edited by printman55; 05-27-2010 at 10:44 AM. Reason: corrected the link

  11. #9
    Join Date
    May 2008
    Posts
    91
    Thanks
    35
    Thanked 0 Times in 0 Posts

    Default

    Were you able to see why there is a delay in navigating between the two pages??

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

    Default

    Are you sure the delay is due to the script, and not perhaps just your server reacting a bit sluggishly? I tried viewing your the test link with JS disabled and still get the 1-2 second delay between page loads.
    DD Admin

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

    printman55 (05-30-2010)

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
  •