Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Jan 2007
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Accessibility options, need help!

    Ok, what i want do is, when the user clicks on a link, javascript changes the spreadsheet to display a larger font.

    Code:
    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;
    }
    Code:
    			  <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.

    Code:
    .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'

  • #2
    New Coder
    Join Date
    Jan 2007
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts
    bumparoonie?

  • #3
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Where is titleElements defined? Can you post the content of setActiveStyleSheet() function?
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #4
    New Coder
    Join Date
    Jan 2007
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    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
    Last edited by ClammyDoo; 05-03-2007 at 12:25 AM.

  • #5
    New Coder
    Join Date
    Jan 2007
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts
    anyone?

  • #6
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    You still didn't define titleElements.
    Code:
    var titleElements = new Array();
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •