如何在IE中设置detect/target"Ignore colors specified on webpages"?
How to detect/target "Ignore colors specified on webpages" setting in IE?
如果启用了 IE "ignore colors specified on webpages",我需要为元素设置样式,但我没有找到这样做的方法。
似乎只有一个 question(据我所知)测试元素的计算背景样式 returns 'rgb(255, 255, 255)' 或“#fff”(如果启用此模式) , 但那不再有效了。
有没有办法用 CSS/JavaScript 检测这种模式?
这帮助我检测了忽略颜色模式:
(function (W, $) {
'use strict';
var $body = $("body")
, interval = $body.data("ignore-color-int") || 4000
, debug = W.location.href.match(/debug=1/) || $body.data("debug")
, C = W.console
, D = C && debug
;
function detect_ignore_color() {
var hcmclass = "no-ignore-color"
, $hcm = $("<p style='position:absolute;top:0;left:-999px;background-color:#878787;'>T</p>")
, testcolor = $hcm.css("background-color").toLowerCase()
;
$.isIgnoreColor = (testcolor !== "#878787" && testcolor !== "rgb(135, 135, 135)");
if ($.isIgnoreColor) {
hcmclass = "ignore-color";
var accessibleElements = document.querySelectorAll('.accessible-hidden-text');
for (var i = 0; i < accessibleElements.length; i++) {
accessibleElements[i].style.opacity = 1;
}
}
$body.removeClass('ignore-color no-ignore-color').addClass(hcmclass);
D && C.log('> ', interval, hcmclass);
}
$(W).resize(detect_ignore_color);
$(function () {
detect_ignore_color();
W.setInterval(detect_ignore_color, interval);
});
}(window, jQuery));
如果启用了 IE "ignore colors specified on webpages",我需要为元素设置样式,但我没有找到这样做的方法。
似乎只有一个 question(据我所知)测试元素的计算背景样式 returns 'rgb(255, 255, 255)' 或“#fff”(如果启用此模式) , 但那不再有效了。
有没有办法用 CSS/JavaScript 检测这种模式?
这帮助我检测了忽略颜色模式:
(function (W, $) {
'use strict';
var $body = $("body")
, interval = $body.data("ignore-color-int") || 4000
, debug = W.location.href.match(/debug=1/) || $body.data("debug")
, C = W.console
, D = C && debug
;
function detect_ignore_color() {
var hcmclass = "no-ignore-color"
, $hcm = $("<p style='position:absolute;top:0;left:-999px;background-color:#878787;'>T</p>")
, testcolor = $hcm.css("background-color").toLowerCase()
;
$.isIgnoreColor = (testcolor !== "#878787" && testcolor !== "rgb(135, 135, 135)");
if ($.isIgnoreColor) {
hcmclass = "ignore-color";
var accessibleElements = document.querySelectorAll('.accessible-hidden-text');
for (var i = 0; i < accessibleElements.length; i++) {
accessibleElements[i].style.opacity = 1;
}
}
$body.removeClass('ignore-color no-ignore-color').addClass(hcmclass);
D && C.log('> ', interval, hcmclass);
}
$(W).resize(detect_ignore_color);
$(function () {
detect_ignore_color();
W.setInterval(detect_ignore_color, interval);
});
}(window, jQuery));