屏幕颜色检测

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

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

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>
相关推荐
用户7917286761972 小时前
opencode-plugin-peers完全指南:OpenCode如何实现 Claude Code式跨会话消息
javascript
andr_gale4 小时前
02_uniapp自定义上凸效果的底部TabBar
前端·javascript·uni-app·移动端
倾听醉梦语5 小时前
React/Vite/Next.js 前端开发工具 SpotPatch:点击页面元素精准定位 JSX/TSX 源码
javascript·react·ai编程·vite·next.js·前端开发工具
2401_881828325 小时前
简易文本处理网页工具|AI 通识课第三次作业
前端·javascript·html
障碍的枫子6 小时前
Vue组件导出&渲染
前端·javascript·vue.js
海带紫菜菠萝汤7 小时前
MSE (Media Source Extensions) 实战:流媒体分块加载与自适应码率
前端·javascript·音视频
张元清7 小时前
React useMount Hook:只在挂载时执行一次的正确姿势 (2026)
javascript·react.js
breeze jiang7 小时前
JavaScript 单例模式:用静态属性保证 Popup 只创建一次
开发语言·javascript·单例模式
No Silver Bullet7 小时前
Vue进阶(贰幺叁)vue.config.js 中 productionSourceMap 作用详解
前端·javascript·vue.js