ClammyDoo
05-02-2007, 06:35 PM
Ok, what i want do is, when the user clicks on a link, javascript changes the spreadsheet to display a larger font.
function getActiveStyleSheet() {
var i, a;
for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
}
return null;
}
<script type="text/javascript">
<!--
document.write("<p>");
document.write(" </p>");
document.write("<h3>Choose your preferred text size</h3>");
document.write("<p>");
document.write("<a href=\"javascript:titleElements[0]='default';setActiveStyleSheet();\" title=\"Default font size\" class=\"default\">Default</a>");
document.write(" | ");
document.write("<a href=\"javascript:titleElements[0]='large';setActiveStyleSheet();\" title=\"Large font size\" class=\"large\">large</a>");
document.write(" | ");
document.write("<a href=\"javascript:titleElements[0]='larger';setActiveStyleSheet();\" title=\"Larger font size\" class=\"larger\">larger</a>");
document.write(" | ");
document.write("<a href=\"javascript:titleElements[0]='largest';setActiveStyleSheet();\" title=\"Largest font size\" class=\"largest\">largest</a>");
document.write("</p>");
document.write("<h3>Choose your preferred colour scheme</h3> ");
document.write("<p>");
document.write("<a href=\"javascript:titleElements[1]='default';setActiveStyleSheet();\" title=\"Red and white\">Housing colours</a>");
document.write(" | ");
document.write("<a href=\"javascript:titleElements[1]='highcontrast';setActiveStyleSheet();\" title=\"Green on black\">High contrast</a>");
document.write("</p>");
//-->
</script>
As you can see this javascript code searches for the class name in the CSS and is supposed to change the text to this class.
.styleSwap .default{
font-size: x-small;
}
.styleSwap .large{
font-size: small;
}
.styleSwap .larger{
font-size: medium;
}
.styleSwap a.HousingColours{
font-weight: normal;
color: #CD1F36;
}
.styleSwap a.highContrast{
font-weight: bold;
color: #00FF33;
background-color: #000000;
}
At the moment this doesn't work at all, whenever i click on one of the text link, nothing happens at all, except getting an error in IE, 'titleElements is undefined'
function getActiveStyleSheet() {
var i, a;
for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
}
return null;
}
<script type="text/javascript">
<!--
document.write("<p>");
document.write(" </p>");
document.write("<h3>Choose your preferred text size</h3>");
document.write("<p>");
document.write("<a href=\"javascript:titleElements[0]='default';setActiveStyleSheet();\" title=\"Default font size\" class=\"default\">Default</a>");
document.write(" | ");
document.write("<a href=\"javascript:titleElements[0]='large';setActiveStyleSheet();\" title=\"Large font size\" class=\"large\">large</a>");
document.write(" | ");
document.write("<a href=\"javascript:titleElements[0]='larger';setActiveStyleSheet();\" title=\"Larger font size\" class=\"larger\">larger</a>");
document.write(" | ");
document.write("<a href=\"javascript:titleElements[0]='largest';setActiveStyleSheet();\" title=\"Largest font size\" class=\"largest\">largest</a>");
document.write("</p>");
document.write("<h3>Choose your preferred colour scheme</h3> ");
document.write("<p>");
document.write("<a href=\"javascript:titleElements[1]='default';setActiveStyleSheet();\" title=\"Red and white\">Housing colours</a>");
document.write(" | ");
document.write("<a href=\"javascript:titleElements[1]='highcontrast';setActiveStyleSheet();\" title=\"Green on black\">High contrast</a>");
document.write("</p>");
//-->
</script>
As you can see this javascript code searches for the class name in the CSS and is supposed to change the text to this class.
.styleSwap .default{
font-size: x-small;
}
.styleSwap .large{
font-size: small;
}
.styleSwap .larger{
font-size: medium;
}
.styleSwap a.HousingColours{
font-weight: normal;
color: #CD1F36;
}
.styleSwap a.highContrast{
font-weight: bold;
color: #00FF33;
background-color: #000000;
}
At the moment this doesn't work at all, whenever i click on one of the text link, nothing happens at all, except getting an error in IE, 'titleElements is undefined'