检测IE“忽略网页上指定的颜色".设定状态 [英] Detecting the IE "Ignore colors specified on webpages" setting state

查看:42
本文介绍了检测IE“忽略网页上指定的颜色".设定状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

IE中有一个可访问性选项(忽略网页上指定的颜色"),该选项可从网页上删除所有CSS颜色/背景色,从而使某些用户更易于查看.

There is an accessibility option ("Ignore colors specified on webpages") in IE that removes all of the CSS color/background-colors from a webpage in order to make it easier to view for some users.

这会通过删除根本无法在前景中输出的有用图像来引起问题.

This can cause issues by removing helpful images that simply cannot be output in the foreground.

有人知道是否有一种方法可以在最终用户浏览器中检测此设置的状态吗?

Does anyone know if there is a way to detect the state of this setting in an end-users browser?

最终,根据此设置的状态,它可以用于显示其他样式,因此,如果可以使用JS检测到它,那就太完美了.

Ultimately it could be used to display alternative styles depending on the state of this setting, so if it can be detected using JS it would be perfect.

但是,我意识到这是一个漫长的尝试,因为允许网页检测浏览器设置可能会打开安全漏洞!但是,对此主题的任何想法都将不胜感激.

However, I realise that it is a long shot as allowing web pages to detect browser settings could open up security holes! But any thoughts on the subject would be greatly appreciated.

推荐答案

您可以使用 getComputedStyle 测试给定的元素;这不会为您节省自定义css(如果用户在辅助功能设置中定义了覆盖css),但是使用剥离的颜色确实可以工作(尽管仍然很麻烦).

You can test a given element with getComputedStyle; this will not save you with custom css (if the user has an override css defined in accessibility settings), but with stripped colors it does work (though it's still a hack).

下面是一个jQuery示例:

A jQuery example follows:

<div id="example" style="background-color:lime;width:40px;height:40px;border:2px solid #000;"></div>
<script>
$(function(){
    alert($("#example").css("backgroundColor"));
});
</script>

这将为您提供白色(255,255,255)和可访问的颜色,以及适当的石灰(0,255,0)和被剥离的颜色-如果您决定使用它,这将使您开始进行此检测.

This will give you white (255,255,255) with accessible colors and the appropriate lime (0,255,0) with stripped colors - this shall get you started with this detection, should you decide to use it.

这篇关于检测IE“忽略网页上指定的颜色".设定状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆