How to check if a user is in high contrast mode using JavaScript or CSS

When you press Shift+ Left+ Alt+, PrintWindows switches to high contrast mode - is there a chance of detecting this on a web page (using JavaScript or CSS)?

Is it likely to detect this in HTTP-Request(aka on the server side, for example, through PHP or Ruby)?

+5
source share
3 answers

According to this article about using CSS sprites in high contrast , in high contrast mode on Windows, the background images should be set to “none” and it will also change the background color. This should override any CSS stylesheet. This way you can execute some javascript to detect it after the initial rendering. Check out its demo page (text "FYI [Not] in high contrast mode".

I have a Mac (using FYI switch Cmd + Alt + Ctrl + 8) and its technique does not work for me, but it says that it works on Windows.

, - JavaScript, CSS () cookie , .

+7

Win8 (desktop-) IE:

<style type="text/css">
// ...
@media screen and (-ms-high-contrast: active) {
   /* any rules may come here, for example: */
   .leftMenu a:hover { text-decoration: underline; }
}
// ...
</style>

, Windows Store. , , , .

MSDN doc: @media, - ms-high-contrast. .

+4

-, . IE.

@media screen and (-ms-high-contrast: black-on-white) {/ * Put your style code ............. * /}

@media screen and (-ms-high-contrast: white-on-black) {/ * Put your style code ............. * /}

+1
source

All Articles