How to use JavaScript to measure how bright a users monitor is?

試著忘記壹切 提交于 2021-02-06 15:47:05

问题


I've noticed that the brightness of computer monitors drastically varies between computers.

As such, this changes the look of web pages greatly.

Is there a way to use JavaScript to automatically detect how bright (or dark) a users monitor is so that I can adjust my web page colors accordingly?

UPDATE

Please note that I do not want manual user involvement. I want this detection to be automatic so that users don't realize I dynamically change the color palette automatically based on the brightness/darkness of their monitor.

UPDATE 2

Please also note that I'm not talking about wanting to adjust/calibrate the end users actual monitor but instead, programatically adjust the color selected to be displayed on the web-page itself. Meaning, if the end user has a darker than normal (brightness) display, I'll instead display a version of my web page that uses brighter colors instead.


回答1:


There's no way to do this programatically. What you'd need to do is write some sort of monitor calibration test, possibly using variations of images like these, showing the user two or more images and asking them to chose the one which looks closer, adjusting colors each time they make a choice, until you feel the changes you've made are accurate.

EDIT: Basically I'm suggesting building something like this.




回答2:


Most of the brightness/darkness settings are a function of the monitor. Nothing in the computer (let alone JavaScript running in a sandbox) is able to access this kind of information - it's mainly a one-way data flow between computer and monitor. Factors such as brightness of the room, and whether there is light behind the monitor will influence the appearance of the screen just as much.

There's no way to get everyone to see your website the way you see it. The sooner you realise that, the easier your life will be.




回答3:


What about a flash/silverlight app instead? It can use the user's camera (if they have one). You could then analyze pictures/video from the camera to make inferences about how much monitor light is reflecting off the user's face.

It would be a very very fragile and complicated app.




回答4:


You can't do that with javascript (and I don't think that you could do that in any other language, at least, without a piece of hardware to help).




回答5:


No. As a general rule, JavaScript is not allowed to find out a whole lot about your computer for security reasons.



来源:https://stackoverflow.com/questions/2883202/how-to-use-javascript-to-measure-how-bright-a-users-monitor-is

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!