Email conversation
From | Azmi Tenikalp |
To | Me |
Subject | Problem with style switcher js & Opera 9 ? |
Date | 7 January 2007 13:47 |
Hi, Mark,
Keeping things brief :
If we look at your stylesheet switching code, using Opera 9 (mine is 9.10
build 8679, running on Win XP) :
http://www.howtocreate.co.uk/tutorials/jsexamples/CSStest/
Everything works fine.
If we go into the frame :
http://www.howtocreate.co.uk/tutorials/jsexamples/CSStest/frame.html
Everything seems to be fine, until you try to refresh the page - when you
discover that Opera 9 sends you back to the default setting.
I am wondering what the difference was between the frame and the top page
...
My proble is :
I don't like to do cut & paste, so I studied your code and tried to make
mine work with what I could learn from your code, but I think I am suffering
from a similar problem.
If you look at [URL] (which incidentally works well with
Firefox & IE, and had worked perfectly up to Opera 8.51) the language
selection function works well in Opera 9, until, you refresh or navigate to
another page, when you return to default.
Not only that, but now clicking on the language option that should have
applied, nothing happens ... Selecting another language, it works again,
so, assuming you had originally selected English, you can select Turkish and
then select English again, and it's fine.
Sorry if I've missed something very simple. I am not a developer /
programmer, I sell sailing hardware.
Many thanks if you can shed some light on this, and I'll be much, much
happier if I've stumbled on some peculiarity (um, bug ?) in Opera 9 - mainly
because it doesn't make sense to me.
Bets regards,
Azmi Tenikalp
From | Me |
To | Azmi Tenikalp |
Subject | Re: Problem with style switcher js & Opera 9 ? |
Date | 7 January 2007 18:01 |
Azmi,
> Everything seems to be fine, until you try to refresh the page - when you
> discover that Opera 9 sends you back to the default setting.
Opera does not fire the onunload event when you reload (since you are not
really unloading, you are reloading). If you need to store the setting
without the unload event firing, you should call the rememberStyle function
immediately after you call the changeStyle function.
> If you look at [URL] (which incidentally works well with
> Firefox & IE, and had worked perfectly up to Opera 8.51) the language
> selection function works well in Opera 9, until, you refresh or navigate to
> another page, when you return to default.
I am not entirely sure this is related to the problems you were having with
my script. After selecting English and reloading, my document.cookie is
'LanguageSelection=Eng', but the page is not in English. I have not looked
too hard into how your script works, but this looks like the bug is probably
elsewhere. I am afraid I cannot see offhand where it is.
Is the language setting used server side or client side?
Mark 'Tarquin' Wilton-Jones - author of http://www.howtocreate.co.uk/
From | Azmi Tenikalp |
To | Me |
Subject | Re: Problem with style switcher js & Opera 9 ? |
Date | 7 January 2007 18:31 |
Hi, Mark,
Thank you very much for your quick response.
Language selection is client side.
I think you have actually seen my problem - you select English, then reload,
and your page is NOT English. Not only that, but the page no longer
responds to the English button (or flag).
Now, select Turkish. You should see the Turkish page. Don't reload, simply
select English, and you should now have the English page, as it should have
appeared from the beginning.
I decided to email you only because I think there is a similar problem on
your site, if you load the frame as a stand-alone page. Am I wrong ?
Cheers,
Azmi
From | Me |
To | Azmi Tenikalp |
Subject | Re: Problem with style switcher js & Opera 9 ? |
Date | 7 January 2007 19:10 |
Azmi,
> I think you have actually seen my problem - you select English, then reload,
> and your page is NOT English. Not only that, but the page no longer
> responds to the English button (or flag).
I can see some problems with your script. Most specifically this one:
// executed when the page unloads - only, don't use it, IE doesn't know
window.onunload = funOnUnloadActions () ;
That is not true. IE can do onunload. However, you should reference the
function. Instead of referencing it, you are executing it immediately, then
assigning its return value 'undefined' as the event handler (which also
means, by the way, that your onload function does not wait for load before
running, because you make the same mistake there.
What you meant to do was this - no parenthesis:
window.onunload = funOnUnloadActions;
This is not your main problem, but you will be happy to hear that I have
discovered the cause. Opera 9 will not enable a stylesheet if you set
disabled to false, if the stylesheet is an alternate stylesheet, since it
thinks it is already enabled (it is enabled, but alternate). My script works
around this without my realising. It does this by first disabling the
stylesheet, then re-enabling it. Then Opera realises it has to change. This
has no adverse effects on any browser, so it is a very simple, clean fix.
Change this:
objStyleSheets[i].disabled = false ;
to this:
objStyleSheets[i].disabled = true;
objStyleSheets[i].disabled = false;
I will report this bug to Opera.
> I decided to email you only because I think there is a similar problem on
> your site, if you load the frame as a stand-alone page. Am I wrong ?
My problems relate to my using onunload in the demo. Yours are unrelated.
Tarquin
From | Azmi Tenikalp |
To | Me |
Subject | Re: Problem with style switcher js & Opera 9 ? |
Date | 7 January 2007 19:28 |
Wow ! I feel humbled. Works a treat.
Thank you very much indeed.
Best regards,
Azmi