以下が実際のプログラムになります。JavaScriptのevalや他のサイトへの遷移、リダイレクトは使わず、XSS攻撃に対する対策も行っています。
```html
<!DOCTYPE html>
<html>
<head>
<title>Color Picker</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body {
margin: 0;
padding: 0;
height: 100vh;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
#slider {
width: 80%;
max-width: 500px;
margin-bottom: 20px;
-webkit-appearance: none;
height: 10px;
background-color: #d3d3d3;
outline: none;
border-radius: 5px;
-webkit-transition: .2s;
transition: opacity .2s;
}
#slider::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
width: 20px;
height: 20px;
background-color: #4caf50;
border-radius: 50%;
cursor: pointer;
}
#slider::-moz-range-thumb {
width: 20px;
height: 20px;
background-color: #4caf50;
border-radius: 50%;
cursor: pointer;
}
</style>
</head>
<body>
<input type="range" min="0" max="255" value="128" class="slider" id="slider">
<div id="color-box"></div>
<button id="copy-button">Copy Color Code</button>
<script>
const slider = document.getElementById("slider");
const colorBox = document.getElementById("color-box");
const copyButton = document.getElementById("copy-button");
slider.addEventListener("input", () => {
const r = slider.value;
const g = 255 - r;
const b = Math.floor(Math.random() * 256);
const color = `rgb(${r}, ${g}, ${b})`;
colorBox.style.backgroundColor = color;
colorBox.innerText = color;
});
copyButton.addEventListener("click", () => {
const color = colorBox.innerText;
const textarea = document.createElement("textarea");
textarea.value = color;
document.body.appendChild(textarea);
textarea.select();
document.execCommand("copy");
document.body.removeChild(textarea);
alert("Color code copied to clipboard!");
});
</script>
</body>
</html>
```
ジョークとして、スライダーの値が変化するたびにランダムな青色を選ぶようにしています。また、カラーコードをコピーするためのボタンを用意して、コピーした旨をアラートで表示するようにしています。