...

View Full Version : Accessibility options, need help!



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("&nbsp;|&nbsp;");
document.write("<a href=\"javascript:titleElements[0]='large';setActiveStyleSheet();\" title=\"Large font size\" class=\"large\">large</a>");
document.write("&nbsp;|&nbsp;");
document.write("<a href=\"javascript:titleElements[0]='larger';setActiveStyleSheet();\" title=\"Larger font size\" class=\"larger\">larger</a>");
document.write("&nbsp;|&nbsp;");
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("&nbsp;|&nbsp;");
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'

ClammyDoo
05-02-2007, 08:43 PM
bumparoonie?

glenngv
05-02-2007, 08:48 PM
Where is titleElements defined? Can you post the content of setActiveStyleSheet() function?

ClammyDoo
05-02-2007, 11:19 PM
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
function setActiveStyleSheet() {
if (titleElements[0]=="" || titleElements[0]==null){
titleElements[0]="default";
}
if (titleElements[1]=="" || titleElements[1]==null){
titleElements[1]="default";
}
var i, a, main;
for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
a.disabled = true;
if(a.getAttribute("title") == titleElements[0]+"_"+titleElements[1]) a.disabled = false;
}
}
}

forgot that lol

ClammyDoo
05-03-2007, 01:11 PM
anyone?

glenngv
05-03-2007, 02:02 PM
You still didn't define titleElements.

var titleElements = new Array();



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum