admin管理员组文章数量:1425104
The browser's default text highlight (selection) background color can be overridden, e.g.:
::selection {
background: #ffb7b7;
}
And the color is browser/OS specific. Is there a way to read the browser's default value using JavaScript or Dart?
The browser's default text highlight (selection) background color can be overridden, e.g.:
::selection {
background: #ffb7b7;
}
And the color is browser/OS specific. Is there a way to read the browser's default value using JavaScript or Dart?
Share Improve this question edited May 23, 2017 at 10:27 CommunityBot 11 silver badge asked May 15, 2015 at 1:43 Cristian AlmstrandCristian Almstrand 7135 silver badges18 bronze badges2 Answers
Reset to default 5I would say that you can't.
Both getComputedStyle(yourElement, '::selection').backgroundColor
and getComputedStyle(yourElement, '::-moz-selection').backgroundColor
will return transparent
as default value and browser won't override os's default.
(Worth to be mentioned that if you set it to transparent, default os' value will be overriden).
I don't think browsers have access to os default preferences, and if they do, they probably won't let any website access it it so easily.
As described at https://stackoverflow./a/39543711/3273929, you can use CSS system colors: https://www.w3/TR/2010/PR-css3-color-20101028/#css2-system, although they are deprecated, they do work.
本文标签: htmlDetermine browser39s default text highlight color using JavaScript or DartStack Overflow
版权声明:本文标题:html - Determine browser's default text highlight color using JavaScript or Dart - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745410434a2657438.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论