Javascript 调整网站的所有文本和背景以符合对比度(对比度交换程序)ADA WCAG
我正在建立一个高级友好网站。我在页面顶部添加了一个按钮,删除所有背景颜色并将其更改为白色,然后将所有文本颜色更改为黑色,以提供一个友好的高级/视力受损网站视图。基本上是试图实现对比度交换。我尝试编写jquery函数来实现这个结果。然而,经过数小时的研究,我提出的函数过于复杂,无法提供我所希望的结果,因为页面上可能有太多的html元素。在jQuery或Javascript中有没有简单的方法来选择所有html元素并应用白色背景和黑色文本?如果有一种方法可以在CSS中实现这一点,那么这种方法也同样有效,但是结果必须是我可以重用的。我需要将此功能复制到500多个站点,而无需手动调整每个站点 大多数页面在Javascript 调整网站的所有文本和背景以符合对比度(对比度交换程序)ADA WCAG,javascript,jquery,html,css,Javascript,Jquery,Html,Css,我正在建立一个高级友好网站。我在页面顶部添加了一个按钮,删除所有背景颜色并将其更改为白色,然后将所有文本颜色更改为黑色,以提供一个友好的高级/视力受损网站视图。基本上是试图实现对比度交换。我尝试编写jquery函数来实现这个结果。然而,经过数小时的研究,我提出的函数过于复杂,无法提供我所希望的结果,因为页面上可能有太多的html元素。在jQuery或Javascript中有没有简单的方法来选择所有html元素并应用白色背景和黑色文本?如果有一种方法可以在CSS中实现这一点,那么这种方法也同样有效
标记上添加类。
所以你可以制作两个css,一个有类,一个没有
例如:
我能够使用上面的jQuery代码来完成这项工作,而无需修改任何CSS。上面的代码将背景更改为黄色,并将文本颜色更改为白色。您可以修改它们以实现不同的行为,例如,黑对黑、黑对白、黑对黄
import java.awt.*;
import javax.swing.*;
public class Test3 implements Icon
{
public static final int NONE = 0;
public static final int DECENDING = 1;
public static final int ASCENDING = 2;
protected int direction;
protected int width = 8;
protected int height = 8;
public Test3(int direction)
{
this.direction = direction;
}
public int getIconWidth()
{
return width+1;
}
public int getIconHeight()
{
return height+1;
}
public void paintIcon(Component c, Graphics g, int x, int y)
{
Color bg = c.getBackground();
Color light = bg.brighter();
Color shade = bg.darker();
int w = width;
int h = height;
int m = w / 2;
if (direction == ASCENDING)
{
g.setColor(shade);
g.drawLine(x, y, x + w, y);
g.drawLine(x, y, x + m, y + h);
g.setColor(light);
g.drawLine(x + w, y, x + m, y + h);
}
if (direction == DECENDING)
{
g.setColor(shade);
g.drawLine(x + m, y, x, y + h);
g.setColor(light);
g.drawLine(x, y + h, x + w, y + h);
g.drawLine(x + m, y, x + w, y + h);
}
}
public static void main(String[] args)
{
Test3 t=new Test3(5);
t.paintIcon(20,10,5,5);
}
}
$('html *:not(script, style, noscript)').each(function() {
$(this).css("background", "none");
$(this).css("background-color", "yellow");
$(this).css("color", "black");
$(this).css("box-shadow", "none");
$(this).css("text-shadow", "none");
});