屏幕颜色检测

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

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

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>
相关推荐
shmily麻瓜小菜鸡1 小时前
TypeScript 知识点补充(第三部分:工程化与高级类型)
前端·javascript·typescript
Hilaku2 小时前
前端的技术判断力是怎么练出来的?
前端·javascript·程序员
miofly3 小时前
GitHub 今日推荐|floorplan:AI 读代码自动画交互式架构地图
javascript·开源·github
Dovis(誓平步青云)4 小时前
拖动关键帧角色就抽动,动画编辑器怎样补齐中间状态
开发语言·前端·javascript·机器学习·编辑器
lpfasd1234 小时前
pywebview与Electron
前端·javascript·electron
行走的陀螺仪4 小时前
Claude Code 从入门到实战(一):安装、登录与第一个Vue项目
前端·javascript·vue.js
vipxieliang4 小时前
解构赋值与展开运算符:现代 JS 提效技巧
javascript
2603_965896624 小时前
JavaScript 原型与原型链
开发语言·前端·javascript
晓得迷路了4 小时前
栗子前端技术周刊第 152 期 - Rspack 2.3、TypeScript 7.1 Beta、Bun 1.4.4...
前端·javascript·css
jktantan14 小时前
Vue keep-alive 切标签后滚动位置回顶?因为 onDeactivated 里读到的 scrollTop 是 0
前端·javascript·vue.js