Choosing both large font and low vision CSS stylesheets concurrently

I'm currently working on designing one of my initial websites and have encountered a dilemma. I have three different stylesheets - one for low vision, one for large font, and the default one. I have three buttons to select these stylesheets, but I'm only able to select one at a time. I am wondering if it is feasible to select two simultaneously, such as low vision and large font, or if I would need to create a fourth stylesheet for this purpose.

Below is the current setup I have:

<link rel="stylesheet" type="text/css" href="css/style.css" title="default" />
<link rel="stylesheet" type="text/css" href="css/large_font.css" title="large_font"     disabled />
<link rel="stylesheet" type="text/css" href="css/low_vision.css" title="low_vision" disabled />

<script type="text/javascript" src="js/styleswitch.js"></script>
<script type='text/javascript' src='js/jquery.min.js'></script>
<script type='text/javascript' src='js/jquery.scrollTo-min.js'></script>
<script type='text/javascript' src='js/jquery.localscroll-min.js'></script>
<script type="text/javascript">
$(document).ready(function () {
$.localScroll();
});
</script> 

<link rel="stylesheet" href="css/slimbox.css" type="text/css" media="screen" /> 
<script type="text/JavaScript" src="js/slimbox.js"></script> 

</head>

<body>

<div id="background">

<div id="wrapper">
    <div id="accessibility">
            <ul id="access_list">
                <li><a href="#" onclick="setActiveStyleSheet('default'); return false;">Default</a> | </li>
                <li><a href="#" onclick="setActiveStyleSheet('large_font'); return false;">Large Font</a> | </li>
                <li><a href="#" onclick="setActiveStyleSheet('low_vision'); return false;">Low Vision</a></li>
            </ul>
        </div>
    <div id="header">
        <div id="site_title"><a href="#">Sean's Site</a></div>

    </div>

Answer №1

If I understand correctly, you are looking to enable or disable individual stylesheets instead of choosing one as the main one.

To achieve this, assign unique IDs to your stylesheets:

<link rel="stylesheet" type="text/css" href="css/style.css" id="default" />
<link rel="stylesheet" type="text/css" href="css/large_font.css" id="large_font" disabled />
<link rel="stylesheet" type="text/css" href="css/low_vision.css" id="low_vision" disabled />

Next, create the JavaScript function toggleStylesheet:

<script type="text/javascript">
  function toggleStylesheet(id) {
    var sheet = document.getElementById(id);
    if (sheet.hasAttribute('disabled')) {
      sheet.removeAttribute('disabled');
    } else {
      sheet.setAttribute('disabled', 'disabled');
    }
  }
</script>

Finally, you can use the function in your user interface:

<ul id="access_list">
  <li><a href="#" onclick="toggleStylesheet('default')">Default Style</a></li>
  <li><a href="#" onclick="toggleStylesheet('large_font')">Large Font Style</a></li>
  <li><a href="#" onclick="toggleStylesheet('low_vision')">Low Vision Style</a></li>
</ul>

For more details on the toggleStylesheet function, check out this Q&A: HTML "link" (stylesheet) disabled attribute

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Why is my jstree create_node event not being triggered even though the node is successfully created?

Even though I am able to successfully create the node, the event is not firing as expected. There are no reported errors in Firefox. What could be causing this issue... $("#treeFile1").jstree("create", null, "outside", { "attr" : { "rel" : "folder" } ...

Is there a way to cycle through an array with each click?

I am currently working on implementing a slider feature that enables users to navigate through different pieces of information by clicking on arrows. However, I have encountered an issue where one arrow works correctly (forward), but the other arrow does n ...

Dependency tree resolution failed during VUE installation

After pulling my project from another computer where it worked fine, I encountered an error when trying to npm install on this machine. Can someone please provide some guidance on how to resolve this issue and prevent similar problems in the future? npm ER ...

Perform a function within another function in Vue

I am dealing with two nested functions in Vue. The parent function needs to retrieve the value of an attribute, while the child function is responsible for using this attribute value to make an API call. How can I ensure that both parts are executed simult ...

Vue, the versatile filtering tool for data tables in HTML

I am currently using Vue to populate an HTML table with data retrieved from an axios call. The table layout is perfect, but I am interested in finding a way (without converting the entire structure to datatables) to enable filtering on each column header. ...

I am having difficulty retrieving all the cssRules for certain pages

Attempting to retrieve all CSS rules using JavaScript has yielded varying results. For instance, on StackOverflow, the code used is: console.log( document.styleSheets[1].href,'rules', document.styleSheets[1].cssRules,'Should be css rules, ...

Use middleware for multiple routes with just one call

I have an API for a dashboard which includes routes such as: /dashboardRoutes/getdata1 /dashboardRoutes/getdata2 . . . /dashboardRoutes/getdata7 On the backend, I am using express router.use to direct these routes to a handler. router.use('/dashboard ...

How to make a routerLink clickable within an anchor tag in Angular 6

I am facing a peculiar issue with a group of hyperlinks. html <div class="col-12 navlinks"> <div class="text-center"> <div class="justify-content-center"> <a class="col-auto d-inline-block whitelink" rou ...

There seems to be a glitch in my JavaScript for loop as it is not iterating for the correct amount that it should

It seems like my for loop is not always iterating 7 times as intended. Sometimes it runs with 5 iterations, other times with 4 or 3. This is the JavaScript code I am using: var start = new Date().getTime(); var end = new Date().getTime(); function timeT ...

Place the background image of the parent element relative to the child element

I am struggling to position the background image of <body> relative to one specific child <div>. <body> <div>content</div> <-- place background image of body relative to this div <div>other content</ ...

How can I retrieve child divs from a cloned div object using jQuery?

I begin by executing this code to obtain a clone of my data var cloned = $(".hoverer:first").clone().attr({id: 'id_'+itm_id, class: 'hoverer-active'}); The main div contains another div with its own id and class, and within that div t ...

How to locate an ID following an AJAX call in jQuery

I am experiencing an issue with a button that is supposed to print a form containing data based on different IDs, where each form has a unique ID. The problem arises when the main page fails to locate these IDs. Below is the JavaScript code responsible f ...

What is the method for eliminating quotes from a URL?

Changing the URL: history.replaceState('data to be passed', 'Title of the page', '<?php echo getAddress(); ?>/?usp-custom-14="'+urldates+'"&usp-custom-8="'+title+'"'); After making changes, it s ...

Trouble with jquery/ajax form submission functionality

I followed a jQuery code for form submission that I found on various tutorial websites, but unfortunately, the ajax functionality doesn't seem to be working. When I try to submit the form, nothing happens at all. I've tried troubleshooting in eve ...

Is it possible to generate multiple services from a single factory in Angular?

Recently, I developed a service called tableService using the following code: app.factory('tableService', [function() { var data = some data; var foo = function (){ //do something to data here }; return { data: data, ...

Transform data into JSON format using AJAX in CodeIgniter

I am having trouble with converting json code in CodeIgniter for pagination. I am using ajax to control the data conversion to json and sending it to the view. Can someone please explain how to do this? In the controller, instead of using a foreach loop, ...

Exploring ElectronJs: The journey to sending messages from ipcMain to IpcRender and awaiting a response

I need help with sending a message to ask the renderer to parse an HTML string mainWindow.webContents.send('parse html', { resp}) The renderer processes the data and sends a reply ipc.on('parse html',function(e,p){ let b ...

Removing an element from an array of objects in Javascript

My situation involves an array containing objects: var items = [{ id: 1, text: "test1" }, { id: 2, text: "test2" }, { id: 3, text: "test3"}]; In addition, I have this specific object: var itemToRemove = { id: 2, text: "test2" }; My objective is to veri ...

Develop a responsive image component with flexible dimensions in React

I am currently working on developing a dynamic image component that utilizes the material-ui CardMedia and is configured to accept specific height and width parameters. The code snippet I have is as follows: interface ImageDim extends StyledProps { wid ...

Exploring Grails: Utilizing Jquery Ajax data array

I am facing an issue with accessing the answers array in my Grails application. The problem arises from a function that creates a data object and populates it with input values: var data={ id:1, answers:[] } $.each($('.panel-body input[type= ...