Thank you Rob for the solution.
I clarify that we are talking about changing the following scripts to achieve compatibility with Safari 5.1.
http://www.alistapart.com/articles/alternate/
http://www.ecst.csuchico.edu/~bertucci/csci245/styleswitcher.htm
I changed something else to distinguish the alternative styles and to avoid reloading the current style.
function setActiveStyleSheet(title) {
var styleTag;
var styleSwitch;
var styleHref='';
for(var i=0; (styleTag = document.getElementsByTagName("link")[i]); i++) {
if(styleTag.getAttribute("title")=="switch") {styleSwitch=styleTag;}
if(styleTag.getAttribute("rel").indexOf("alternate stylesheet")!=-1 && styleTag.getAttribute("title")) {
if(styleTag.getAttribute("title")==title) {styleHref=styleTag.getAttribute("href");}
}
}
if (styleSwitch.getAttribute("href") != styleHref) {styleSwitch.setAttribute("href",styleHref);}
return false;
}
James,
to use cookies you can try to replace also that function:
function getActiveStyleSheet() {
var styleTag;
var styleSwitch;
var styleTitle='';
for(var i=0; (styleTag = document.getElementsByTagName("link")[i]); i++) {
if(styleTag.getAttribute("title")=="switch") {styleSwitch=styleTag;}
}
for(var i=0; (styleTag = document.getElementsByTagName("link")[i]); i++) {
if(styleTag.getAttribute("rel").indexOf("alternate stylesheet")!=-1 && styleTag.getAttribute("title")) {
if(styleTag.getAttribute("href")==styleSwitch.getAttribute("href ")) {styleTitle=styleTag.getAttribute("title");}
}
}
return styleTitle;
}
I used that solution on the website
http://www.umrio.com