Jvalej

Navigation

Skip navigation.

Search

Site navigation

Email conversation

FromJvalej
ToMe
Subjectstylesheet switcher and remembering a style in Opera and Mozilla
Date30 April 2004 11:12
Hello!

I'm adding a style sheet switcher feature to my pages,
and came across your solution.

And I'd like to ask if remembering style sheet
selection on reload can also somehow work in Opera and
Mozilla, and not only in IE? Or maybe I'm doing
something wrong and it does work?..

Thank you!
FromMe
ToJvalej
SubjectRe: stylesheet switcher and remembering a style in Opera and Mozilla
Date30 April 2004 11:46
I have just updated that script (yesterday night) for a minor bug that
should not affect those browsers unless you are using a custom DTD
(unlikely). If you are, you may need to download a new version.

My script works (and remembers the style) in Mozilla, Opera, Safari and IE.
If it is not working it may be because those browsers are configured not to
accept cookies, or because you have not set a lifetime for the cookie
(defaults to browser session).

Also, Mozilla and Opera will _only_ remember a style if you click a link on
the page or the page is replaced with JavaScript, not if you reload, click
'back' or close the window (because in those cases, the onunload event does
not fire).

Hope this helps, but if you are still having problems, please feel free to
contact me again, including a URL, and I will take a look and see if I can
work out why it is failing.


Mark 'Tarquin' Wilton-Jones - author of http://www.howtocreate.co.uk/
FromJvalej
ToMe
SubjectRe: stylesheet switcher and remembering a style in Opera and Mozilla
Date30 April 2004 12:25
Hello!

I undunderstand now. I wanted the style sheet to be
remembered exactly in these cases, like IE does.

Thank you for your reply, and your great work! :)
FromMe
ToJvalej
SubjectRe: stylesheet switcher and remembering a style in Opera and Mozilla
Date30 April 2004 13:19
if you want, you can call the save function repeatedly using a timer (for
example). It will not actually do anything unless they have actually
changed stylesheet, so it shouldn't annoy them.

[ED. It is much better to make it save every time it is changed.
changeStyle('blah');rememberStyle('styleStore',365);]
FromJvalej
ToMe
SubjectRe: stylesheet switcher and remembering a style in Opera and Mozilla
Date30 April 2004 13:28
I'm not a coder myself, can you please write an
example of how to implement this timer function.

Thanks!
FromMe
ToJvalej
SubjectRe: stylesheet switcher and remembering a style in Opera and Mozilla
Date30 April 2004 14:03
This will attempt to save the style choice evey 5 seconds:

<script type="text/javascript"><!--
window.setInterval('saveStyle();',5000);
function saveStyle() { rememberStyle('styleTestStore',10); }
//--></script>
FromJvalej
ToMe
SubjectRe: stylesheet switcher and remembering a style in Opera and Mozilla
Date30 April 2004 14:18
Thank you! :)
Does it matter where to put the code - in head or in
body section?
FromMe
ToJvalej
SubjectRe: stylesheet switcher and remembering a style in Opera and Mozilla
Date30 April 2004 14:41
it should not matter, but just to be sure, put it at the end, just before
the </body> tag
FromJvalej
ToMe
SubjectRe: stylesheet switcher and remembering a style in Opera and Mozilla
Date30 April 2004 14:53
Thank you for everything! :)
This site was created by Mark "Tarquin" Wilton-Jones.
Don't click this link unless you want to be banned from our site.