屏幕颜色检测

免费在线屏幕测试 - 专业显示器检测工具 | 视觉族

别人的网站很好,我写了一个差不多的。

html 复制代码
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
<title>DisplayTest</title>
</head>
<style>
body {  }
button { width:30px; height:30px; border:1px solid gray; }
a { text-decoration:none; }
#panel { text-align:center; }
</style>
<body>
<div id="panel">
<button class="button_color"></button> <button class="button_color"></button> <button class="button_color"></button> <button class="button_color"></button> <button class="button_color"></button> <button class="button_color"></button> <button class="button_color"></button> <button class="button_color"></button> <button id="button_fullscreen">↕</button><br>
<a href="https://www.shijuezu.com/" target="_blank">视觉族</a> <a href="https://www.htmlcolorname.com/" target="_blank">HTMLColorName</a>
</div>
<script>
var colors = [ 'white', 'black', 'red', 'green', 'blue', 'yellow', 'fuchsia', 'cyan' ];
var id = 0;
var timerId;
var delay = 2000;

var buttons = document.querySelectorAll('.button_color');
for (i=0; i<buttons.length; i++) {
	buttons[i].style.background = colors[i];
    buttons[i].addEventListener('click', function() {		
		id = Array.prototype.indexOf.call(buttons, this);
		document.body.style.background = colors[id];
		timerId = setTimeout(() => { panel.style.display = 'none'; document.documentElement.style.cursor = 'none'; }, delay);
	});
}

function EEFullscreen() {
	if (!document.fullscreenElement){
		document.documentElement.requestFullscreen();
		button_fullscreen.textContent = '╬';
	} else {
		document.exitFullscreen();
		button_fullscreen.textContent = '↕';
	}
}

function hidePanel() {
	panel.style.display = 'none';
	document.documentElement.style.cursor = 'none';
}

button_fullscreen.onclick = function(){
	EEFullscreen();
}

document.onkeydown = function(e){
	//console.log(e.code);
	if (e.code === 'KeyF') {
		EEFullscreen();
	} else if (e.code === 'ArrowLeft') {
		if (id == 0) {
			id = colors.length - 1;
		} else {
			id--;
		}
		buttons[id].focus();
		document.body.style.background = colors[id];
		timerId = setTimeout(() => {  }, delay);
	} else if (e.code === 'ArrowRight') {
		if (id == colors.length - 1) {
			id = 0;
		} else {
			id++;
		}
		buttons[id].focus();
		document.body.style.background = colors[id];
		timerId = setTimeout(() => { hidePanel(); }, delay);
	}
}

document.onmousemove = function(e){
	clearTimeout(timerId);
	panel.style.display = 'block';
	document.documentElement.style.cursor = 'auto';
	timerId = setTimeout(() => { hidePanel(); }, delay);
}

timerId = setTimeout(() => { hidePanel(); }, delay);
</script>
</body>
</html>
相关推荐
半个落月1 天前
LangChain.js Agent Memory 实战(下):用 Milvus 构建可检索的长期记忆
javascript·langchain
半个落月1 天前
LangChain.js Agent Memory 实战(上):从内存对话、文件持久化到截断与摘要
javascript·langchain
linux_cfan1 天前
17 · 引擎适配器全景:HLS/DASH/Vimeo/Mux/Cast
前端·javascript·音视频
何何____1 天前
Vue 生命周期详解
前端·javascript
默_笙1 天前
💫 闭包是个背包:拆解小米前端面试题里的三道"闭包陷阱"
前端·javascript·面试
尾善爱看海2 天前
《JavaScript 数组操作全攻略:12 类 API + 30 个实战场景 + 20 个避坑指南》
前端·javascript·面试
OpsEye2 天前
为什么你的 Agent 莫名烧钱?聊聊循环调用的兜底方案
javascript·ai编程
linux_cfan2 天前
16 · `custom-media-element`:属性拦截与转发
前端·javascript·音视频
右耳朵猫AI2 天前
Web前端周刊2026W38 | React 19.3 发布、StyleX 深潜、jsdom 30.1 提速
前端·javascript·react.js·typescript·node.js
落魄大学生之流水线上谋生计2 天前
GreenLife Carbon · OpenHarmony 智慧低碳生态平台
javascript