(PHP) How to detect that user's computer/browser is in Dark Mode?

后端 未结 2 1410
闹比i
闹比i 2021-01-13 03:06

Lately I am updating my software to support dark mode, in response to research that looking at a paper-white background display is bad for the eyes and for sleep rhythms. Is

2条回答
  •  攒了一身酷
    2021-01-13 03:43

    Since PHP executes on the server without any knowledge of the client, there is no direct way of finding this out.

    If it is possible to detect the color mode in JS, you could embed a small JS script to your site, that sets a cookie. Cookies are transmitted to the server on request, so PHP is able to query them.

提交回复
热议问题