问题
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?
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.
回答1:
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).
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>
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.
回答2:
Yes you can, I can't find the link I was looking for, but the following link will get you started: http://www.w3.org/TR/css3-color/#css-system
Best thing about it is you don't need Javascript.
来源:https://stackoverflow.com/questions/12855917/detecting-the-ie-ignore-colors-specified-on-webpages-setting-state